Created
June 2, 2017 16:58
-
-
Save Willmo36/3d129c3ca15d0285e0253bffef57db9a to your computer and use it in GitHub Desktop.
Some freactal types
This file contains hidden or 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
declare module "freactal" { | |
interface ProvideStateArg<P, S, C, E> { | |
middleware?: any[]; | |
initialState: (props: P, freactal: {}) => S; | |
computed?: FreactalComputed<C, S>; | |
effects?: FreactalEffectDefinitions<E, S>; | |
} | |
export type InjectStateProps<P, S, C = null, E = null> = P & { state: S & C, effects: FreactalEffectUsages<E, S> }; | |
type InjectStateArg<P, S, C, E> = (p: InjectStateProps<P, S, C, E>) => JSX.Element; | |
export var provideState: <P, S, C = null, E = null>(a: ProvideStateArg<P, S, C, E>) => Function; | |
export var injectState: <P, S, C = null, E = null>(f: InjectStateArg<P, S, C, E>) => JSX.Element; | |
export var softUpdate: <S>(fn: (s: S) => Partial<S>) => S; | |
export type UpdateFn<S> = (s: S) => S; | |
type FreactalComputed<T, S> = { | |
[P in keyof T]: (s: S & T) => T[P]; | |
} | |
type FreactalEffectUsages<T, S> = { | |
[P in keyof T]: (arg: T[P]) => Promise<S>; | |
} | |
type FreactalEffectDefinitions<T, S> = { | |
[P in keyof T]: | |
((effects: FreactalEffectUsages<T, S>, arg: T[P], getState: () => S) => UpdateFn<S>) | |
| ((effects: FreactalEffectUsages<T, S>, arg: T[P], getState: () => S) => Promise<UpdateFn<S>>) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment