npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@weavedev/store

v1.1.0

Published

Opinionated drop-in redux store with redux-saga

Readme

store

Build Status - Travis CI Test Coverage - Code Climate MIT NPM

Opinionated drop-in Redux store with Redux-Saga

Install

npm i @weavedev/store

API documentation

We generate API documentation with TypeDoc.

API Documentation

Usage

Initialization

Basic initialization

The recommended way to create the store is with the init() function.

import { init } from '@weavedev/store/init';

init();

Custom initialization with middlewares

If you want to use your own middlewares you can pass them as arguments.

import { init } from '@weavedev/store/init';
import { logger, router, uploader } from './middlewares';

init(logger, router, uploader);

Automatic initialization

When the store object is imported and window.store has not already been initialized this package will initialize it for you.

import { store } from '@weavedev/store';
NOTE

The purpose of automatic initialization and the importable store object are to provide an easy way to migrate an existing project. Manually initializing the store is recommended.

Reducers

Adding reducers

Adding reducers to the window.storeReducers object registers them on the store and allows you to dispatch actions on them.

import { Action, Reducer } from 'redux';

// Clear message action
export const CLEAR_MESSAGE = 'CLEAR_MESSAGE';
type ClearMessage = Action<typeof CLEAR_MESSAGE>;
export const clearMessage = (): ClearMessage => ({
    type: CLEAR_MESSAGE,
});

// Set message action
export const SET_MESSAGE = 'SET_MESSAGE';
interface SetMessage extends Action<typeof SET_MESSAGE> {
    message: string;
}
export const setMessage = (message: string): SetMessage => ({
    type: SET_MESSAGE,
    message,
});

// Message reducer
window.storeReducers.myMessageReducer = (state: string = 'default value', action: StoreActions): string => {
    switch(action.type) {
        case 'CLEAR_MESSAGE':
            return '';
        case 'SET_MESSAGE':
            return action.message;
        default:
            return state;
    }
};

declare global {
    interface StoreReducersMap {
        myMessageReducer: Reducer<string, StoreActions>;
    }

    interface StoreActionsMap {
        myMessageReducer: SetMessage | ClearMessage;
    }
}

Removing reducers

After removing a reducer from window.storeReducers it will no longer listen to dispatched actions. After a reducer is removed from window.storeReducers its state will be removed.

delete window.storeReducers.myMessageReducer;

Sagas

Adding sagas

Adding sagas to the window.storeSagas object registers them on the store and runs them to start listening to dispatched actions.

import { call, takeLatest } from 'redux-saga/effects';
import { SetMessage } from './myMessageReducer';

// Message saga
window.storeSagas.myMessageSaga = function* (): Iterator<any> {
    yield takeLatest('SET_MESSAGE', function* (action: SetMessage): Iterator<any> {
        yield call(console.log, action.message);
    });
};

Removing sagas

After removing a saga from window.storeSagas it will no longer listen to dispatched actions and if the saga is running it will be cancelled.

delete window.storeSagas.myMessageSaga;

Global types

This package provides the following global types

StoreActions

Any actions known to the store. Useful when creating reducers.

function myReducer(state: string, action: StoreActions): string {
    // ...
}

StoreActionsMap

Any actions you want to use with the store you can add to the StoreActionsMap. These actions will be available on the global StoreActions type.

declare global {
    interface StoreActionsMap {
        myReducer: Action<'MY_ACTION'>;
    }
}

StoreReducersMap

Any reducers you want to use with the store you can add to the StoreReducersMap. This wil also bind the types to StoreState.

declare global {
    interface StoreReducersMap {
        myReducer: Reducer<string, StoreActions>;
    }
}

StoreSagasMap

It exists. You will probably not need it. But just in case you are looking for it, here it is.

declare global {
    interface StoreSagasMap {
        mySaga: Saga;
    }
}

StoreState

The StoreState type describes the return type of window.store.getState(). Useful when using stored values.

const state: StoreState = window.store.getState();

Logging

Setting window.DEV_MODE to true before initializing will enable logging in the console and with the Chrome Redux DevTools.

import { init } from '@weavedev/store/init';

window.DEV_MODE = true;

init();

License

MIT

Made by Paul Gerarts and Weave