Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-subspace

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-subspace - npm Package Compare versions

Comparing version 2.0.2-alpha to 2.0.3-alpha

32

lib/enhancers/applySubspaceMiddleware.js

@@ -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 @@ };

20

lib/index.d.ts

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc