UNPKG

@rx-angular/state

Version:

@rx-angular/state is a light-weight, flexible, strongly typed and tested tool dedicated to reduce the complexity of managing component state and side effects in angular

60 lines 1.96 kB
import { InjectionToken, Provider } from '@angular/core'; import { AccumulationFn } from '@rx-angular/state/selections'; import { SchedulerLike } from 'rxjs'; export type RX_STATE_CONFIGS = 'Accumulator' | 'Scheduler'; interface RxStateConfigFn { kind: RX_STATE_CONFIGS; providers: Provider[]; } /** * Injection token for the default accumulator function. * * @example * providers: [ * { * provide: RX_ACCUMULATOR_FN, * useValue: (state, slice) => ({ ...state, ...slice }) * } * ] */ export declare const RX_ACCUMULATOR_FN: InjectionToken<AccumulationFn>; /** * Provider function to specify a custom `AccumulationFn` for `RxState` to use. * @param fn */ export declare function withAccumulatorFn(fn: AccumulationFn): RxStateConfigFn; /** * Injection token for the default state scheduler * * @example * providers: [ * { * provide: RX_STATE_SCHEDULER, * useValue: asapScheduler * } * ] */ export declare const RX_STATE_SCHEDULER: InjectionToken<SchedulerLike | "sync">; /** * Provider function to specify a scheduler for `RxState` to perform state updates & emit new values. * @param scheduler */ export declare function withScheduler(scheduler: SchedulerLike | 'sync'): RxStateConfigFn; /** * Provider function to specify synchronous (no) scheduling for `RxState`. The state computations * will be fully synchronous instead of using the default `queueScheduler` */ export declare function withSyncScheduler(): RxStateConfigFn; /** * This function is used to provide the configuration for the rxState function. * * You can provide multiple configurations at once. * * You can use these functions to provide the configuration: * - withAccumulatorFn - to provide a custom accumulator function * - withScheduler - to provide a custom scheduler * */ export declare function provideRxStateConfig(...configs: RxStateConfigFn[]): Provider[]; export {}; //# sourceMappingURL=provide-rx-state-config.d.ts.map