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

redux-loop-immutable

v2.0.1

Published

ImmutableJS Extensions for Redux Loop

Downloads

999

Readme

redux-loop-immutable

ImmutableJS helpers for use with Redux Loop

Installation

The latest Redux Loop Immutable requires the latest redux-loop version. If you need to support an older version of redux-loop, use an older version of redux-loop-immutable.

yarn add redux-loop-immutable

API

combineReducers(reducersMap)

This is simply an ImmutableJS-optimized version of the combineReducers provided by core redux-loop. Instead of the default state being a plain object, it is an Immutable.Map instance.

Arguments

  • reducersMap: Object<string, ReducerFunction> – a plain object map of keys to nested reducers, just like the combineReducers you would find in Redux itself.

Examples

import { combineReducers } from 'redux-loop-immutable';
import reducerWithSideEffects from './reducer-with-side-effects';
import plainReducer from './plain-reducer';

export default combineReducers({
  withEffects: reducerWithSideEffects,
  plain: plainReducer
});

mergeChildReducers(parentResult, action, childMap)

NOTE: mergeChildReducers is deprecated as of version 2.0.0. It will be removed in 3.0.0. combineReducers and reduceReducers (which needs no immutable helper) should cover the cases where mergeChildReducers is needed. If you need to use it temporarily without a console warning, use DEPRECATED_mergeChildReducers(parentResult, action, childMap). This will also be removed in 3.0.0 though.

This is an ImmutableJS-optimized version of the mergeChildRedcuers provided by core redux-loop. Like that version of mergeChildReducers, it is a more generalized version of combineReducers that allows you to nest reducers underneath a common parent that has functionality of its own (rather than restricting the parent to simply passing actions to its children like combineReducers does)

  • parentResult: Immutable.Map | loop(Immutable.Map, Cmd) – The result from the parent reducer before any child results have been applied.
  • action: Action – a redux action
  • childMap: Object<string, ReducerFunction> – a plain object map of keys to nested reducers, similar to the map in combineReducers. However, a key can be given a value of null to have it removed from the state.

Examples

import { mergeChildReducers } from 'redux-loop-immutable';
import {getModel, isLoop} from 'redux-loop';
import { fromJS } from 'immutable'
import pageReducerMap from './page-reducers';

// a simple reducer that keeps track of your current location and nests the correct
//child reducer for that location at state.data

const initialState = fromJS({
   location: 'index'
   //data will be filled in with the result of the child reducer
});

function parentReducer(state = initialState, action){
  if(action.type !== 'LOCATION_CHANGE')
     return state;
     
  return state.set('location', action.newLocation);
}

export default function reducer(state, action){
  const parentResult = parentReducer(state, action);
  
  let location;
  if(isLoop(parentResult))
    location = getModel(parentResult).get('location');
  else
    location = parentResult.get('location');
   
  const childMap = {data: pageReducerMap[location]};
  
  return mergeChildReducers(parentResult, action, childMap);
}

Support

Potential bugs, generally discussion, and proposals or RFCs should be submitted as issues to this repo, we'll do our best to address them quickly. We use this library as well and want it to be the best it can! For questions about using the library, submit questions on StackOverflow with the redux-loop tag.

Contributing

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. Multiple language translations are available at contributor-covenant.org