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

easy-ts-redux

v0.0.8

Published

### Write Redux in TS with minimum or zero boilerplate

Readme

Easy-TS-Redux

Write Redux in TS with minimum or zero boilerplate

Installation

npm i easy-ts-redux

or

yarn add easy-ts-redux

Usage

Two major part: easyStore() and easyReducer()

 

Create Slices with easyReducer()

Parameters:

  • initialState(required) - must be some kind of object
  • prefix(required) - its for avoiding action name collision (came from ReduxDucks)
import { easyReducer } from "easy-ts-redux";

const { reducer, action, actionWithPayload, wartchers } = easyReducer(
  { foo: "bar", isEasy: true },
  "easy"
);
export default reducer;

It's genetic so you can restrict the state type

import { easyReducer } from "easy-ts-redux";

interface State {
  foo: string;
  isEasy: boolean;
}

const { reducer, action, actionWithPayload, wartchers } = easyReducer<State>(
  { foo: "bar", isEasy: true },
  "easy"
);

export default reducer;
  • reducer is the Slice itself (it should be the default export)
  • action() and actionWithPayload() for create your actions
  • watchers() return all saga watcher function (parameter of easyStore())

 

Create actions with action() and actionWithPayload()

Both function has the same parameters, except actionWithPayload exept the type of the payload

  • type(required) - unique identifier for the action
  • saga(optional) - generator function for async data or dispatching other actions. (if provided this function get payload from action call)
  • reducerFn(optional) - actual reducer function what modify the state

Important

  • Either saga or reducerFn must provided (or both), otherwide the action throw an error

  • saga always has one arg whitch is the type prop

  • reducerFn use immer internally, this means you can freely mutate the state.

import {easyReducer} from 'easy-ts-redux';
import {put} from 'redux-saga/effects'

const {reducer, action, actionWithPayload, wartchers} = easyReducer({foo: 'bar'}, 'easy');

export const toggleEasy = action({
  type: 'TOGGLE_EASY',
  reducerFn: (state) => {
    state.isEasy = !state.isEasy;
  }
})

export const srtFoo = actionWithPayload<string>({
  type: 'SET_FOO',
  saga: function*(__reducerFnType, payload) { // __reducerFnType always provided, payload from action call
    //yield some async call
    const newPayload = payload + 'easy'
    yield put({type: __reducerFnType, payload: newPayload}) //call the reducerFn
  }
  reducerFn: (state, payload) => {
    state.foo = payload;
  }
})

const fooWatchers = watchers; // Unfortunatly you can'r export watchers out of the box
export fooWatchers;
export default reducer;

Drawback! The reducerFn's payload always be any inside actionWithPayload()


 

Create store with easyStore()

Parameters:

  • reducer(required) - object of Slices
  • watchers(optional) - Array of generated watchers
  • middlewares(optional) - Array of middlewares
import {easyStore} from 'easy-ts-redux';
import foo. {fooWatchers} from "./foo"; // Since you export the reducer as default, you can use any name

//optionally create Store type
export type Store = {
  foo: ReturnType<typeof foo>
}

const store = easyStore({foo}, [fooWatchers])

This method do the followings:

  • generate and run sagaMiddleware
  • parse all watchers and combine them into a single array, what is consumed by sagaMiddleware
  • configure @redux-devtools/extension for development mode
  • create actual store

Useful docs