@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
35 lines • 1.2 kB
TypeScript
import { Actions, ActionTransforms, RxActions } from './types';
/**
* Manage events in components and services in a single place
*
* @example
*
* interface UI {
* search: string,
* submit: void
* };
*
* import { rxActions } from '@rx-angular/state/actions';
*
* @Component({...})
* export class Component {
* ui = rxActions<{ name: string }>(({transforms}) => transforms({name: v => v}));
*
* name$ = this.ui.name$; // Observable<string> - listens to name changes
* emitName = this.ui.name; // (name: string) => void - emits name change
* sub = this.ui.onName(o$ => o$.pipe(), console.log) // () => void - stops side effect
*
* onInit() {
* const name$ = this.ui.name$; // Observable<string> - listens to name changes
* const emitName = this.ui.name; // (name: string) => void - emits name change
* const stop = this.ui.onName(o$ => o$.pipe(), console.log) // () => void - stops side effect
* stop();
* }
*
* }
*
*/
export declare function rxActions<T extends Partial<Actions>, U extends ActionTransforms<T> = object>(setupFn?: (cfg: {
transforms: (t: U) => void;
}) => void): RxActions<T, U>;
//# sourceMappingURL=rx-actions.d.ts.map