thesmo-redux-dispatchdeprecated

Redux dispatch which provides performing any store action at any nested level in one line

Usage no npm install needed!

<script type="module">
  import thesmoReduxDispatch from 'https://cdn.skypack.dev/thesmo-redux-dispatch';
</script>

README

npm GitHub GitHub last commit npm GitHub top language code style: prettier

About

This package provides you using Redux store as tree. It gives you possibility of having updates and obtaining values by node path. You can apply changes to one node, multiple nodes or whole state at once. Changes can be applied via calculating field.

Functions

getReducer

Returns reducer for Redux store which can be used with following actions

type Args = {
    defaultState?: object;
};

type Signature = ({ defaultState = {} }: Args) => Reducer

getUpdateMultipleNodesAction

Returns action for multiple nodes update via calculating fields

type UpdateNodePayload = {
    nodePath: string;
    calcField: SafeCF<any, any>;
};

type UpdateMultipleNodesPayload = { 
    updates: UpdateNodePayload[] 
};

type Args = UpdateMultipleNodesPayload;

type Signature = ({ updates }: Args) 
    => Action<string> & UpdateMultipleNodesPayload

getUpdateNodeAction

Returns action for single node update via calculating field

type UpdateNodePayload = {
    nodePath: string;
    calcField: SafeCF<any, any>;
};

type Args = UpdateNodePayload;

type Signature = ({
    calcField,
    nodePath
}: Args) => Action<string> & UpdateNodePayload

getUpdateWholeStateAction

Returns action for updating whole store via calculating field

type UpdateWholeStatePayload = {
    calcField: SafeCF<any, any>;
};

type Args = UpdateWholeStatePayload;

type Signature = ({ 
    calcField
}: Args) => Action<string> & UpdateWholeStatePayload