-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
you now need to use the function fx(newState, Effects) from the package to retu BREAKING CHANGE: no more _fx field, now use fx function
- Loading branch information
1 parent
949086b
commit e9dff24
Showing
7 changed files
with
169 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
export interface StateWithFx { | ||
[key: string]: any | ||
newState: any | ||
_fx: { [key: string]: any } | ||
export type Effects = { [key: string]: any } | ||
|
||
export type BatchEffects = [Effects] | ||
|
||
export interface StateWithFx<S> { | ||
state: S | ||
effects: Effects | BatchEffects | ||
} | ||
|
||
export class StateWithFx<S> { | ||
constructor(state: S, effects: Effects) { | ||
this.state = state | ||
this.effects = effects | ||
} | ||
} | ||
|
||
export function hasFX<S>(s: S | StateWithFx<S>): s is StateWithFx<S> { | ||
return s instanceof StateWithFx | ||
} | ||
|
||
export function hasFX(s: any): s is StateWithFx { | ||
return s && typeof s._fx === 'object' && '_fx' in s && 'newState' in s | ||
export function fx<S>(state: S, effects: Effects): StateWithFx<S> { | ||
return new StateWithFx(state, effects) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.