-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangtao
committed
Nov 10, 2017
1 parent
15bf8b4
commit feb573c
Showing
8 changed files
with
133 additions
and
36 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { StateDict } from "../core"; | ||
import { DefaultPickedProps } from "./types"; | ||
|
||
export function defaultPropsPicker<S>( | ||
{ _arenaScene: state }: StateDict<S>, | ||
{ _arenaScene: actions }: { _arenaScene: {} } | ||
): DefaultPickedProps<S> { | ||
return Object.assign({}, state, { | ||
actions | ||
}); | ||
} | ||
|
||
const defaultActions = { | ||
setState: (state: any) => ({ type: ActionTypes.ARENA_SCENE_SET_STATE, state }) | ||
}; |
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,2 +1,10 @@ | ||
export { default as bundleToComponent } from "./bundleToComponent"; | ||
export { default as bundleToElement } from "./bundleToElement"; | ||
export { | ||
DefaultPickedProps, | ||
Diff, | ||
Omit, | ||
DefaultState, | ||
SceneBundleNoS, | ||
SceneBundleBase | ||
} from "./types"; |
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,3 +1,69 @@ | ||
import { ComponentType } from "react"; | ||
import { ActionCreatorsMapObject } from "redux"; | ||
import { PropsPicker, SceneReducer, SceneBundleOptions } from "../core"; | ||
|
||
export type Diff<T extends string, U extends string> = ({ [P in T]: P } & | ||
{ [P in U]: never } & { [x: string]: never })[T]; | ||
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>; | ||
|
||
export type DefaultPickedProps<S, A extends ActionCreatorsMapObject> = { | ||
actions: A; | ||
} & S; | ||
|
||
export type DefaultState = {}; | ||
|
||
export type DefaultActions<S> = { setState: (state: Partial<S>) => void }; | ||
|
||
export type SceneBundleBase<P> = { | ||
Component: ComponentType<P>; | ||
saga?: (...params: any[]) => any; | ||
options?: SceneBundleOptions; | ||
}; | ||
|
||
export type SceneBundleNoS<P, A extends ActionCreatorsMapObject, PP> = { | ||
actions: A; | ||
propsPicker: PropsPicker<P, DefaultState, A, PP>; | ||
reducer: SceneReducer<DefaultState>; | ||
} & SceneBundleBase<P>; | ||
|
||
export type SceneBundleNoR<P, S, A extends ActionCreatorsMapObject, PP> = { | ||
state: S; | ||
actions: A; | ||
propsPicker: PropsPicker<P, S, A, PP>; | ||
}; | ||
|
||
export type SceneBundleNoPP<P, S, A extends ActionCreatorsMapObject> = { | ||
state: S; | ||
actions: A; | ||
reducer: SceneReducer<DefaultState>; | ||
} & SceneBundleBase<P>; | ||
|
||
export type SceneBundleNoA<P, S, PP> = { | ||
state: S; | ||
reducer: SceneReducer<DefaultState>; | ||
propsPicker: PropsPicker<P, DefaultState, DefaultActions<S>, PP>; | ||
} & SceneBundleBase<P>; | ||
|
||
export type SceneBundleNoSR<P, A extends ActionCreatorsMapObject, PP> = { | ||
actions: A; | ||
propsPicker?: PropsPicker<P, DefaultState, DefaultActions<DefaultState>, PP>; | ||
} & SceneBundleBase<P>; | ||
|
||
export type SceneBundleNoSPP<P, S, A extends ActionCreatorsMapObject> = { | ||
actions: A; | ||
reducer: SceneReducer<S>; | ||
} & SceneBundleBase<P>; | ||
|
||
export type SceneBundleNoSA<P, PP> = { | ||
reducer: SceneReducer<DefaultState>; | ||
propsPicker: PropsPicker<P, DefaultState, DefaultActions<DefaultState>, PP>; | ||
} & SceneBundleBase<P>; | ||
|
||
export type SceneBundleNoAPP<P, S> = { | ||
state: S; | ||
reducer: SceneReducer<S>; | ||
} & SceneBundleBase<P>; | ||
|
||
export type SceneBundleNoASPP<P> = { | ||
reducer: SceneReducer<DefaultState>; | ||
} & SceneBundleBase<P>; |