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-in-place

v0.0.9

Published

> A react/redux library to manage and organize redux's store attributes.

Downloads

4

Readme

redux-in-place

A react/redux library to manage and organize redux's store attributes.

Motivation

Every application tends to grow and one of many difficulties is to keep your code clean and organized; so it happens with Redux's store, as the store grows many attributes appears and it become hard to track to which domain or page they belong. Redux-in-place proposes to organize the store's attribute tree in a simple and understandable way.

How it works

Let's suppose that in the store we have an user that is authenticated who wants to buy some books. Store's properties would look like something like this.

{ 
  username: 'Foo',
  registrationDate: '2016-12-10',
  bookName: 'Last wish',
  author: 'Andrzej Sapkowski'
}

When those attributes grow will become harder and harder to assert to which domain those properties come from. With redux-in-place we could do:

{ 
  User: {
    username: 'Foo',
    registrationDate: '2016-12-10'
  },
  Book: {
    name: 'Last wish',
    author: 'Andrzej Sapkowski' 
  }
}

It becomes easier to read and to organize store's properties.

How to use

First of all

npm install redux-in-place --save

Then you user your redux like you normally would but instead of exporting it, you should connect your reduce with redux-in-place like this:

import { placeReducer } from 'redux-in-place';

export const UPDATE_INFORMATION = 'UPDATE_INFORMATION';

const initialState = {
  name: '',
  author: '',
};

const reducer = (state = initialState, action) => ({
  [UPDATE_INFORMATION]: {
    ...state,
    name: action.name,
    author: action.author,
  }
}[action.type] || state);

export default placeReducer('Book', reducer);

Then in your React component:

import { connectReducer } from 'redux-in-place';
import { connect } from 'react-redux';

import bookReducer from './bookReducer';
//...code ommited for sake of simplicity
const ConnectedBook = connect(
  ({ Book }) => ({
    author: Book.author,
    name: Book.name
  })
)(BookComponent);

export default connectReducer(bookReducer)(ConnectedBook);

That's it, simple like that, now all your reducer properties will be on 'Book'.

Thanks

@AntonioSchmidt - For all the help with this lib, the effort to make it open-source, document and help me with it testing and development. My sincere thank you!

License

Copyright (c) 2016 Gabriel Reitz Giannattasio Licensed under the MIT license.