MCPcopy Create free account
hub / github.com/ngrx/platform / withMethods

Function withMethods

modules/signals/src/with-methods.ts:36–65  ·  view source on GitHub ↗
(
  methodsFactory: (
    store: Prettify<
      StateSignals<Input['state']> &
        Input['props'] &
        Input['methods'] &
        WritableStateSource<Input['state']>
    >
  ) => Methods
)

Source from the content-addressed store, hash-verified

34 * ```
35 */
36export function withMethods<
37 Input extends SignalStoreFeatureResult,
38 Methods extends MethodsDictionary,
39>(
40 methodsFactory: (
41 store: Prettify<
42 StateSignals<Input['state']> &
43 Input['props'] &
44 Input['methods'] &
45 WritableStateSource<Input['state']>
46 >
47 ) => Methods
48): SignalStoreFeature<Input, { state: {}; props: {}; methods: Methods }> {
49 return (store) => {
50 const methods = methodsFactory({
51 [STATE_SOURCE]: store[STATE_SOURCE],
52 ...store.stateSignals,
53 ...store.props,
54 ...store.methods,
55 });
56 if (typeof ngDevMode !== 'undefined' && ngDevMode) {
57 assertUniqueStoreMembers(store, Reflect.ownKeys(methods));
58 }
59
60 return {
61 ...store,
62 methods: { ...store.methods, ...methods },
63 } as InnerSignalStore<Record<string, unknown>, SignalsDictionary, Methods>;
64 };
65}

Callers 15

withMyEntityFunction · 0.90
withUrlizerFunction · 0.90
withCallbackFunction · 0.90
withLoadEntitiesFunction · 0.90
storeFactoryFunction · 0.90
withCustomFeature1Function · 0.90
withCustomFeature2Function · 0.90

Calls 1

assertUniqueStoreMembersFunction · 0.90

Tested by 7

withMyEntityFunction · 0.72
withUrlizerFunction · 0.72
withCallbackFunction · 0.72
withLoadEntitiesFunction · 0.72
storeFactoryFunction · 0.72
withCustomFeature1Function · 0.72
withCustomFeature2Function · 0.72