redux-subspace
Advanced tools
Comparing version 2.0.2-alpha to 2.0.3-alpha
@@ -29,4 +29,26 @@ 'use strict'; | ||
var _getState = subspacedStore.getState; | ||
var _dispatch = subspacedStore.dispatch; | ||
var namespace = subspacedStore.namespace, | ||
rootStore = subspacedStore.rootStore, | ||
subspaceTypes = subspacedStore.subspaceTypes, | ||
processAction = subspacedStore.processAction; | ||
var middlewareApi = { | ||
getState: function getState() { | ||
return _getState.apply(undefined, arguments); | ||
}, | ||
dispatch: function dispatch() { | ||
return _dispatch.apply(undefined, arguments); | ||
}, | ||
rootStore: rootStore, | ||
namespace: namespace, | ||
subspaceTypes: subspaceTypes, | ||
processAction: processAction | ||
}; | ||
var chain = middlewares.map(function (middleware) { | ||
return middleware(subspacedStore); | ||
return middleware(middlewareApi); | ||
}).map(function (pipeline) { | ||
@@ -47,8 +69,8 @@ return typeof pipeline === 'function' ? { dispatch: pipeline } : pipeline; | ||
var getState = _redux.compose.apply(undefined, _toConsumableArray(getStateChain))(subspacedStore.getState); | ||
var dispatch = _redux.compose.apply(undefined, _toConsumableArray(dispatchChain))(subspacedStore.dispatch); | ||
_getState = _redux.compose.apply(undefined, _toConsumableArray(getStateChain))(subspacedStore.getState); | ||
_dispatch = _redux.compose.apply(undefined, _toConsumableArray(dispatchChain))(subspacedStore.dispatch); | ||
return _extends({}, subspacedStore, { | ||
getState: getState, | ||
dispatch: dispatch | ||
getState: _getState, | ||
dispatch: _dispatch | ||
}); | ||
@@ -55,0 +77,0 @@ }; |
@@ -25,8 +25,8 @@ /** | ||
export interface ProcessActionCallback<TReturn> { | ||
(action: Redux.Action): TReturn | ||
(action: Redux.Action): TReturn; | ||
} | ||
export interface ProcessAction { | ||
(action: Redux.Action, callback: ProcessActionCallback<void>): undefined | ||
<TReturn>(action: Redux.Action, callback: ProcessActionCallback<TReturn>, defaultValue: TReturn): TReturn | ||
(action: Redux.Action, callback: ProcessActionCallback<void>): undefined; | ||
<TReturn>(action: Redux.Action, callback: ProcessActionCallback<TReturn>, defaultValue: TReturn): TReturn; | ||
} | ||
@@ -38,3 +38,3 @@ | ||
subspaceTypes: SubspaceType[]; | ||
processAction: ProcessAction | ||
processAction: ProcessAction; | ||
} | ||
@@ -73,2 +73,3 @@ | ||
*/ | ||
export type GetState<TState> = () => TState; | ||
@@ -84,4 +85,13 @@ | ||
export interface SubspaceMiddlewareAPI<TState, TRootState> { | ||
getState: GetState<TState>; | ||
dispatch: Redux.Dispatch<TState>; | ||
rootStore: Redux.Store<TRootState>; | ||
namespace: string; | ||
subspaceTypes: SubspaceType[]; | ||
processAction: ProcessAction; | ||
} | ||
export interface SubspaceMiddleware { | ||
<TState>(subspace: Subspace<TState, any>): ({ getState?: GetStateMiddleware<TState>, dispatch?: DispatchMiddleware<TState> }); | ||
<TState>(subspace: SubspaceMiddlewareAPI<TState, any>): ({ getState?: GetStateMiddleware<TState>, dispatch?: DispatchMiddleware<TState> }); | ||
} | ||
@@ -88,0 +98,0 @@ |
{ | ||
"name": "redux-subspace", | ||
"version": "2.0.2-alpha", | ||
"version": "2.0.3-alpha", | ||
"description": "Create isolated subspaces of a Redux store", | ||
@@ -5,0 +5,0 @@ "author": "Michael Peyper", |
@@ -15,3 +15,17 @@ /** | ||
const chain = middlewares.map((middleware) => middleware(subspacedStore)) | ||
let getState = subspacedStore.getState | ||
let dispatch = subspacedStore.dispatch | ||
const { namespace, rootStore, subspaceTypes, processAction } = subspacedStore | ||
const middlewareApi = { | ||
getState: (...args) => getState(...args), | ||
dispatch: (...args) => dispatch(...args), | ||
rootStore, | ||
namespace, | ||
subspaceTypes, | ||
processAction | ||
} | ||
const chain = middlewares.map((middleware) => middleware(middlewareApi)) | ||
.map((pipeline) => typeof pipeline === 'function' ? { dispatch: pipeline } : pipeline) | ||
@@ -22,4 +36,4 @@ | ||
const getState = compose(...getStateChain)(subspacedStore.getState) | ||
const dispatch = compose(...dispatchChain)(subspacedStore.dispatch) | ||
getState = compose(...getStateChain)(subspacedStore.getState) | ||
dispatch = compose(...dispatchChain)(subspacedStore.dispatch) | ||
@@ -26,0 +40,0 @@ return { |
@@ -25,8 +25,8 @@ /** | ||
export interface ProcessActionCallback<TReturn> { | ||
(action: Redux.Action): TReturn | ||
(action: Redux.Action): TReturn; | ||
} | ||
export interface ProcessAction { | ||
(action: Redux.Action, callback: ProcessActionCallback<void>): undefined | ||
<TReturn>(action: Redux.Action, callback: ProcessActionCallback<TReturn>, defaultValue: TReturn): TReturn | ||
(action: Redux.Action, callback: ProcessActionCallback<void>): undefined; | ||
<TReturn>(action: Redux.Action, callback: ProcessActionCallback<TReturn>, defaultValue: TReturn): TReturn; | ||
} | ||
@@ -38,3 +38,3 @@ | ||
subspaceTypes: SubspaceType[]; | ||
processAction: ProcessAction | ||
processAction: ProcessAction; | ||
} | ||
@@ -73,2 +73,3 @@ | ||
*/ | ||
export type GetState<TState> = () => TState; | ||
@@ -84,4 +85,13 @@ | ||
export interface SubspaceMiddlewareAPI<TState, TRootState> { | ||
getState: GetState<TState>; | ||
dispatch: Redux.Dispatch<TState>; | ||
rootStore: Redux.Store<TRootState>; | ||
namespace: string; | ||
subspaceTypes: SubspaceType[]; | ||
processAction: ProcessAction; | ||
} | ||
export interface SubspaceMiddleware { | ||
<TState>(subspace: Subspace<TState, any>): ({ getState?: GetStateMiddleware<TState>, dispatch?: DispatchMiddleware<TState> }); | ||
<TState>(subspace: SubspaceMiddlewareAPI<TState, any>): ({ getState?: GetStateMiddleware<TState>, dispatch?: DispatchMiddleware<TState> }); | ||
} | ||
@@ -88,0 +98,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
60760
1176
0