@weavedev/redux-lazy
TypeScript icon, indicating that this package has built-in type declarations

0.1.11 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @weavedev/redux-lazy

Weekly Downloads

140

Version

0.1.11

License

MIT

Unpacked Size

12.1 kB

Total Files

14

Last publish

Collaborators

  • weavebot