@angular-redux/store
Version:
Angular bindings for Redux
46 lines (45 loc) • 1.58 kB
TypeScript
import { Comparator, Selector, Transformer } from '../components/selectors';
/**
* Selects an observable from the store, and attaches it to the decorated
* property.
*
* ```ts
* import { select } from '@angular-redux/store';
*
* class SomeClass {
* @select(['foo','bar']) foo$: Observable<string>
* }
* ```
*
* @param selector
* A selector function, property name string, or property name path
* (array of strings/array indices) that locates the store data to be
* selected
*
* @param comparator Function used to determine if this selector has changed.
*/
export declare function select<T>(selector?: Selector<any, T>, comparator?: Comparator): PropertyDecorator;
/**
* Selects an observable using the given path selector, and runs it through the
* given transformer function. A transformer function takes the store
* observable as an input and returns a derived observable from it. That derived
* observable is run through distinctUntilChanges with the given optional
* comparator and attached to the store property.
*
* Think of a Transformer as a FunctionSelector that operates on observables
* instead of values.
*
* ```ts
* import { select$ } from 'angular-redux/store';
*
* export const debounceAndTriple = obs$ => obs$
* .debounce(300)
* .map(x => 3 * x);
*
* class Foo {
* @select$(['foo', 'bar'], debounceAndTriple)
* readonly debouncedFooBar$: Observable<number>;
* }
* ```
*/
export declare function select$<T>(selector: Selector<any, T>, transformer: Transformer<any, T>, comparator?: Comparator): PropertyDecorator;