Skip to content

Commit

Permalink
fix(formula): getStateBySelector to object param
Browse files Browse the repository at this point in the history
  • Loading branch information
nampdn committed Nov 29, 2019
1 parent bb72f82 commit 82a296f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/formula/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ export const getState = withStore(
},
)

export interface GetStateBySelectorProps {
param: Formula
selector: (state: any) => any
}
export const getStateBySelector = withStore(
(paramFormula: Formula, selector: (state: any) => any) => async (
_: any,
(config: GetStateBySelectorProps) => async (
payload: any,
store: Store,
...rest: any[]
) => {
const param = await Promise.resolve(paramFormula(_, ...rest))
const { param, selector } = config
const arg = await Promise.resolve(param(payload, ...rest))
const state = store.getState()
return selector(param)(state)
return selector(arg)(state)
},
)

0 comments on commit 82a296f

Please sign in to comment.