UNPKG

1.58 kBTypeScriptView Raw
1import { Comparator, Selector, Transformer } from '../components/selectors';
2/**
3 * Selects an observable from the store, and attaches it to the decorated
4 * property.
5 *
6 * ```ts
7 * import { select } from '@angular-redux/store';
8 *
9 * class SomeClass {
10 * @select(['foo','bar']) foo$: Observable<string>
11 * }
12 * ```
13 *
14 * @param selector
15 * A selector function, property name string, or property name path
16 * (array of strings/array indices) that locates the store data to be
17 * selected
18 *
19 * @param comparator Function used to determine if this selector has changed.
20 */
21export declare function select<T>(selector?: Selector<any, T>, comparator?: Comparator): PropertyDecorator;
22/**
23 * Selects an observable using the given path selector, and runs it through the
24 * given transformer function. A transformer function takes the store
25 * observable as an input and returns a derived observable from it. That derived
26 * observable is run through distinctUntilChanges with the given optional
27 * comparator and attached to the store property.
28 *
29 * Think of a Transformer as a FunctionSelector that operates on observables
30 * instead of values.
31 *
32 * ```ts
33 * import { select$ } from 'angular-redux/store';
34 *
35 * export const debounceAndTriple = obs$ => obs$
36 * .debounce(300)
37 * .map(x => 3 * x);
38 *
39 * class Foo {
40 * @select$(['foo', 'bar'], debounceAndTriple)
41 * readonly debouncedFooBar$: Observable<number>;
42 * }
43 * ```
44 */
45export declare function select$<T>(selector: Selector<any, T>, transformer: Transformer<any, T>, comparator?: Comparator): PropertyDecorator;