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 🙏

© 2024 – Pkg Stats / Ryan Hefner

immudux

v2.0.2

Published

Immutable Centered Redux

Downloads

16

Readme

immudux

The Complete Immutable JS Version of Redux

Benefits

  • Only Immutable JS support
  • Much more performant (only calls subscribers that are affected by the reducer change)
  • No need for Reselect
  • Standard API calling action (coming soon)

Usage

npm i --save immudux

75% of the implementation is the same as redux, main differences are:

  • Actions MUST be Immutable JS Maps
  • Actions MUST have a type property
  • Reducer returns two things, newState: Map and affected: Array
  • Subscribers subscribe via a function and an affected array

If you use createReducer, it handles affected so you just need to return the new state. If not it should be returned like this:

{
  newState: Immutable JS Map,
  affected: Array<string>
}

Subscribers subscribe to a certain affected area and they get called when that domain changes. If you subscribe to ['todo'] and a reducer updates in ['counter'] it won't call the subscriber. Any reducer having 'todo' in affected updates that subscriber.

Function Usage

createReducer(reducers: Object): (action: Map, state: Map) => { affected: Array<string>; newState: Map }

Description: Takes a reducer object in like this { area: { CONSTRUCT: Function; HANDLER: Function } } and returns a reducer combining the object, which are supplied to the create store.

Specifications: The input must have a domain Map with at least a CONSTRUCT function inside it:

Valid Inputs:

{ 
  todo: { 
    CONSTRUCT: () => fromJS([{id: 1, text: 'hello World'}])
  }
}

{ 
  todo: { 
    CONSTRUCT: () => fromJS([{id: 1, text: 'hello World'}]),
    ADD_TODO: (action, state) => state.push(fromJS({id: 2, text: 'state is the selected state'}))
  }
}

Invalid Inputs:

{ 
  todo: { 
    NOT_CONSTRUCT: () => fromJS([{id: 1, text: 'hello World'}]),
  }
}

{ 
  todo: { 
    CONSTRUCT: () => fromJS([{id: 1, text: 'hello World'}]),
    NOT_A_FUNCTION: ''
  }
}

createStore(reducer: Function): { getState: Function; dispatch: Function; subscribe: Function }

Description: createStore is the core part of immudux, making the store required for everything. It takes in a reducer and returns an API to read the state through getState() and subscribing and updating through dispatch.

Specifications: The input reducer function must take an action and a state and return a regular JS object with newState and affected. createStore then iterates through the selectors, calling each one that is affected then setting the state as newState.

applyMiddleWare(...funcs: Array<Function>) => Function

Works exactly the same as redux's applyMiddleWare just keep in mind that actions are Immutable Maps

Credit

gaearon for redux which this is just an adjustment to. gajus for canonical reducer composition which this is based off of