Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 6x 54x 6x 3x 93x 6x 15x 6x 300x 6x 58x 300x 300x 60x 38x 38x 6x 18x | import { Subject } from 'rxjs';
export type Dispatcher = Subject<AnyAction<any>>;
export type DispatchersList = Subject<Subject<AnyAction<any>>>;
export interface AnyAction<T = any> {
type: T;
// Allows any extra properties to be defined in an action.
[extraProps: string]: any;
}
export type Reducer<R = any> = (state: any, action: AnyAction<string>) => R;
export type Constants = { [key: string]: string };
export type Dispatch = <A extends AnyAction<any>>(action: A) => A;
export interface AnyItem {
id: string | number;
// Allows any extra properties to be defined in an action.
[extraProps: string]: any;
}
export const genRandomString = () =>
Math.random().toString(36).substring(2, 10);
export const defaultGenId = (): string => {
return ([1e7].toString() + -1e3 + -4e3 + -8e3 + -1e11).replace(
/[018]/g,
(c: any) =>
(
c ^
(window.crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
).toString(16)
);
};
export const ensureArray = <T>(items: any): T[] =>
Array.isArray(items) ? items : [items];
export const createConstant = (name: string, constant: string) =>
`${name}/${constant}`;
export const createConstants = <C extends string>(
name: string,
constants: C[]
) =>
constants.reduce<{ [key in C]: string }>((acc, constant) => {
acc[constant] = createConstant(name, constant);
return acc;
}, {} as any);
export const wrapDispatchSubject = (dispatch$: Subject<any>) => <
A extends AnyAction<any>
>(
action: A
): A => {
dispatch$.next(action);
return action;
};
export const getType = (action: AnyAction) =>
action.type.split('/', 2).join('/');
|