MCPcopy
hub / github.com/rx-angular/rx-angular / set

Method set

libs/state/src/lib/rx-state.service.ts:331–366  ·  view source on GitHub ↗

* @internal

(
    keyOrStateOrProjectState: Partial<State> | ProjectStateFn<State> | Key,
    stateOrSliceProjectFn?: ProjectValueFn<State, Key>,
  )

Source from the content-addressed store, hash-verified

329 * @internal
330 */
331 set<Key extends keyof State>(
332 keyOrStateOrProjectState: Partial<State> | ProjectStateFn<State> | Key,
333 stateOrSliceProjectFn?: ProjectValueFn<State, Key>,
334 ): void {
335 if (
336 typeof keyOrStateOrProjectState === 'object' &&
337 stateOrSliceProjectFn === undefined
338 ) {
339 this.accumulator.nextSlice(keyOrStateOrProjectState);
340 return;
341 }
342
343 if (
344 typeof keyOrStateOrProjectState === 'function' &&
345 stateOrSliceProjectFn === undefined
346 ) {
347 this.accumulator.nextSlice(
348 keyOrStateOrProjectState(this.accumulator.state),
349 );
350 return;
351 }
352
353 if (
354 isKeyOf<State>(keyOrStateOrProjectState) &&
355 typeof stateOrSliceProjectFn === 'function'
356 ) {
357 const state: Partial<State> = {};
358 state[keyOrStateOrProjectState] = stateOrSliceProjectFn(
359 this.accumulator.state,
360 );
361 this.accumulator.nextSlice(state);
362 return;
363 }
364
365 throw new Error('wrong params passed to set');
366 }
367
368 /**
369 * @description

Callers 15

setupStateFunction · 0.95
parseMethod · 0.45
generateTypescriptDocsFunction · 0.45
constructorMethod · 0.45
constructorMethod · 0.45
appFunction · 0.45
ngOnInitMethod · 0.45
appFunction · 0.45
constructorMethod · 0.45
filterMethod · 0.45
toggleDoneMethod · 0.45
addTodoMethod · 0.45

Calls 1

isKeyOfFunction · 0.90

Tested by 6

setupStateFunction · 0.36
strMethod · 0.36
constructorMethod · 0.36
strMethod · 0.36
constructorMethod · 0.36
buildItemListFunction · 0.36