Skip to main content

Function: withFeatureFactory()

withFeatureFactory<Input, Output>(factoryFn): SignalStoreFeature<Input, Output>

Defined in: libs/ngrx-toolkit/src/lib/with-feature-factory.ts:35

Allows to pass properties, methods, or signals from a SignalStore to a feature.

Typically, a signalStoreFeature can have input constraints on

function withSum(a: Signal<number>, b: Signal<number>) {
return signalStoreFeature(
withComputed(() => ({
sum: computed(() => a() + b())
}))
);
}

signalStore(
withState({ a: 1, b: 2 }),
withFeatureFactory((store) => withSum(store.a, store.b))
);

Type Parameters

Input extends SignalStoreFeatureResult

Output extends SignalStoreFeatureResult

Parameters

factoryFn

(store) => SignalStoreFeature<Input, Output>

Returns

SignalStoreFeature<Input, Output>