Skip to main content
Version: Current

slice

@rotorsoft/act-root


@rotorsoft/act-root / act/src / slice

Function: slice()

Call Signature​

slice(): SliceBuilder<{ }, { }, { }, { }, Readonly<{[key: string]: unknown; id: string; name: string; }>>

Defined in: libs/act/src/builders/slice-builder.ts:44

Creates a new slice builder for composing partial states with scoped reactions.

Slices enable vertical slice architecture by grouping related states and reactions into self-contained feature modules. Reactions defined in a slice are type-scoped to events from that slice's states only.

Returns​

SliceBuilder<{ }, { }, { }, { }, Readonly<{[key: string]: unknown; id: string; name: string; }>>

Example​

Single-state slice with typed dispatch

const CounterSlice = slice()
.withState(Counter)
.on("Incremented")
.do(async function resetCounter(event, _stream, app) {
await app.do("reset", target, {});
})
.to("counter-target")
.build();

See​

Call Signature​

slice<TSchemaReg, TEvents, TActions, TStateMap, TActor>(): SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>

Defined in: libs/act/src/builders/slice-builder.ts:45

Creates a new slice builder for composing partial states with scoped reactions.

Slices enable vertical slice architecture by grouping related states and reactions into self-contained feature modules. Reactions defined in a slice are type-scoped to events from that slice's states only.

Type Parameters​

TSchemaReg​

TSchemaReg extends SchemaRegister<TActions>

TEvents​

TEvents extends Schemas = { }

TActions​

TActions extends Schemas = { }

TStateMap​

TStateMap extends Record<string, Schema> = { }

TActor​

TActor extends Readonly<{[key: string]: unknown; id: string; name: string; }> = Readonly<{[key: string]: unknown; id: string; name: string; }>

Returns​

SliceBuilder<TSchemaReg, TEvents, TActions, TStateMap, TActor>

Example​

Single-state slice with typed dispatch

const CounterSlice = slice()
.withState(Counter)
.on("Incremented")
.do(async function resetCounter(event, _stream, app) {
await app.do("reset", target, {});
})
.to("counter-target")
.build();

See​