Options
All
  • Public
  • Public/Protected
  • All
Menu

@weavedev/redux-lazy - v0.1.11

redux-lazy

GPL-3.0 NPM

Quick save component for data storage in Redux

Install

npm i @weavedev/redux-lazy

API documentation

We generate API documentation with TypeDoc.

API Documentation

Usage

Creating

In this example we create a reducer and action to save an object to the store containing a message.

import { ReduxLazy } from '@weavedev/redux-lazy';

interface MyState {
    message: string;
}

const SAVE_ACTION = 'SAVE_ACTION';
const defaultState: MyState = {
    message: 'Hello!',
};
export const message = new ReduxLazy(SAVE_ACTION, defaultState);

// If you are also using our store package (@weavedev/store)
window.storeReducers.message = message.reducer;

declare global {
    interface StoreReducersMap {
        message: typeof message.reducer;
    }

    interface StoreActionsMap {
        message: typeof message.actions;
    }
}

Saving

You can update the state by calling .run(). The argument type matches that of the default state provided in the constructor.

import { message } from './message';

// If you are also using our store package (@weavedev/store)
window.store.dispatch(message.run({ message: 'Hey!' }));

License

GPL-3.0

Made by Paul Gerarts and Weave

Generated using TypeDoc