
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
redux-struct
Advanced tools
Set of tools providing a solid structure to keep and update entities in Redux store
redux-struct is a set of tools providing a solid structure to keep and update entities in Redux store.
$ npm i redux-struct
redux-struct reducer to your root reducer:import { combineReducers } from 'redux';
import { reducer as struct } from 'redux-struct';
const rootReducer = combineReducers({
struct,
// other reducers
});
redux-struct actions. Implementation depends on tool that you chosen for mantaining side effects in Redux. Here is example for redux-saga:import { put, call } from 'redux-saga/effects';
import { startStructFetch, stopStructFetch } from 'redux-struct';
import api from 'utils/api';
export function* fetchStruct(structId, url) {
try {
yield put(startStructFetch(structId));
const result = yield call(api.get, url);
yield put(stopStructFetch(structId, result));
return { result };
} catch (error) {
yield put(stopStructFetch(structId, error));
return { error };
}
};
import { call } from 'redux-saga/effects';
import { fetchStruct } from 'utils/sagas';
function* fetchUser(id) {
const { result, error } = yield call(fetchStruct, `user/${id}`, `api/user/${id}`);
};
import { getStruct } from 'utils/sagas';
const mapStateToProps = (state, props) => {
const { userId } = props;
return {
user: getStruct(userId, state),
};
}
Struct is a piece of data that can represent any entity or collection of entities: user, array of orders, etc. Struct are initiated automatically when first action with given structId is dispatched. All structs has same initial structure:
{
isFetching: false,
data: null,
error: null,
}
reducer()The struct reducer. Should be mounted to your Redux state at struct
getStruct(structId:String, [getStructState:Function]), returns state => struct:ObjectSelector, gets struct by name. Will return default struct if nothing was found. Has optional second argument getStructState() that is used to select the mount point of the redux-struct reducer from the root Redux reducer. It defaults to state => state.struct.
startStructFetch(structId:String)Action creator, sets structs isFetching to true and error to null. Ignores other fields.
stopStructFetch(structId:String, payload:any)Action creator, sets structs isFetching to false. If payload is instance of Error, sets error to payload and keep the data. Otherwise sets data to payload and error to null.
updateStruct(structId:String, payload:any)Action creator, merges struct with payload.
resetStruct(structId:String)Action creator, resets struct to it's default state.
FAQs
Toolset to keep and update async data state in Redux store when working with REST APIs
The npm package redux-struct receives a total of 6 weekly downloads. As such, redux-struct popularity was classified as not popular.
We found that redux-struct demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.