forked from reduxjs/redux
-
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.
- Loading branch information
Showing
17 changed files
with
121 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ignore] | ||
.*/lib | ||
.*/test | ||
|
||
[include] | ||
|
||
[libs] | ||
|
||
[options] |
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,21 +1,25 @@ | ||
import Store from './Store'; | ||
/* @flow */ | ||
|
||
import StoreClass from './Store'; | ||
import combineReducers from './utils/combineReducers'; | ||
|
||
import type { State, Action, Reducer, Dispatch, Store } from './types'; | ||
|
||
export default function createStore( | ||
reducer, | ||
initialState | ||
) { | ||
const finalReducer = typeof reducer === 'function' ? | ||
reducer: Reducer, | ||
initialState: State | ||
): Store { | ||
var finalReducer = typeof reducer === 'function' ? | ||
reducer : | ||
combineReducers(reducer); | ||
|
||
const store = new Store(finalReducer, initialState); | ||
var store = new StoreClass(finalReducer, initialState); | ||
|
||
return { | ||
dispatch: ::store.dispatch, | ||
subscribe: ::store.subscribe, | ||
getState: ::store.getState, | ||
getReducer: ::store.getReducer, | ||
replaceReducer: ::store.replaceReducer | ||
dispatch: store.dispatch.bind(store), | ||
subscribe: store.subscribe.bind(store), | ||
getState: store.getState.bind(store), | ||
getReducer: store.getReducer.bind(store), | ||
replaceReducer: store.replaceReducer.bind(store) | ||
}; | ||
} |
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,10 @@ | ||
export type State = any; | ||
export type Action = Object; | ||
export type IntermediateAction = any; | ||
export type Dispatch = (a: Action | IntermediateAction) => any; | ||
export type Reducer<S, A> = (state: S, action: A) => S; | ||
export type ActionCreator = (...args: any) => Action | IntermediateAction | ||
export type Middleware = (methods: { dispatch: Dispatch, getState: () => State }) => (next: Dispatch) => Dispatch; | ||
export type Store = { dispatch: Dispatch, getState: State, subscribe: Function, getReducer: Reducer, replaceReducer: void }; | ||
export type CreateStore = (reducer: Function, initialState: any) => Store; | ||
export type HigherOrderStore = (next: CreateStore) => CreateStore; |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
/* @flow */ | ||
|
||
/** | ||
* Composes functions from left to right | ||
* @param {...Function} funcs - Functions to compose | ||
* @return {Function} | ||
*/ | ||
export default function compose(...funcs) { | ||
export default function compose(...funcs: Array<Function>): Function { | ||
return funcs.reduceRight((composed, f) => f(composed)); | ||
} |
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,3 +1,5 @@ | ||
export default function identity(value) { | ||
/* @flow */ | ||
|
||
export default function identity<T>(value: T): T { | ||
return value; | ||
} |
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,5 @@ | ||
export default function isPlainObject(obj) { | ||
/* @flow */ | ||
|
||
export default function isPlainObject(obj: Object): boolean { | ||
return obj ? typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype : false; | ||
} |
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