Skip to content

Commit

Permalink
refactor(Sitore) move AnyFn
Browse files Browse the repository at this point in the history
  • Loading branch information
tja4472 committed Mar 9, 2019
1 parent 7d0a5ac commit a3c4ee4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
11 changes: 2 additions & 9 deletions modules/store/src/action_creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// = https://github.com/Hotell/rex-tils
// ==========

import { Action } from './models';
import { Action, AnyFn } from './models';

export function createAction<T extends string>(type: T): Action<T>;
export function createAction<
Expand Down Expand Up @@ -32,15 +32,8 @@ export function createAction<
return action;
}

/**
* Use this type definition instead of `Function` type constructor
*/
type AnyFunction = (...args: any[]) => any;

/**
* Simple alias to save keystrokes when defining JS typed object maps
*/
type StringMap<T> = { [key: string]: T };
export type ActionsUnion<A extends StringMap<AnyFunction>> = ReturnType<
A[keyof A]
>;
export type ActionsUnion<A extends StringMap<AnyFn>> = ReturnType<A[keyof A]>;
2 changes: 2 additions & 0 deletions modules/store/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export type Action<T extends string = string, P = void> = P extends void
}> &
Readonly<P>;

export type AnyFn = (...args: any[]) => any;

export type TypeId<T> = () => T;

export type InitialState<T> = Partial<T> | TypeId<Partial<T>> | void;
Expand Down
4 changes: 1 addition & 3 deletions modules/store/src/selector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Selector, SelectorWithProps } from './models';

export type AnyFn = (...args: any[]) => any;
import { AnyFn, Selector, SelectorWithProps } from './models';

export type MemoizedProjection = { memoized: AnyFn; reset: () => void };

Expand Down

0 comments on commit a3c4ee4

Please sign in to comment.