MCPcopy
hub / github.com/angular/angular / s

Function s

packages/forms/signals/test/node/resource.spec.ts:68–85  ·  view source on GitHub ↗
(p)

Source from the content-addressed store, hash-verified

66
67 it('Takes a simple resource which reacts to data changes', async () => {
68 const s: SchemaOrSchemaFn<Cat> = function (p) {
69 const RES = createManagedMetadataKey((_state, params: Signal<{x: string} | undefined>) =>
70 resource({
71 params,
72 loader: async ({params}) => `got: ${params.x}`,
73 }),
74 );
75 metadata(p.name, RES, ({value}) => ({x: value()}));
76
77 validate(p.name, ({state}) => {
78 const remote = state.metadata(RES)!;
79 if (remote.hasValue()) {
80 return {message: remote.value(), kind: 'custom'};
81 } else {
82 return undefined;
83 }
84 });
85 };
86
87 const cat = signal({name: 'cat'});
88

Callers 2

computed_spec.tsFile · 0.50

Calls 11

resourceFunction · 0.90
createManagedMetadataKeyFunction · 0.85
metadataFunction · 0.85
valueFunction · 0.85
applyEachFunction · 0.85
validateAsyncFunction · 0.85
mapMethod · 0.80
metadataMethod · 0.65
hasValueMethod · 0.65
valueMethod · 0.65
validateFunction · 0.50

Tested by

no test coverage detected