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-stored

v1.1.2

Published

A react and redux implementation that stores models and call it globally from actions using middleware and from prop's component.

Downloads

4

Readme

Redux Stored

A react-redux implementation that stores your logic and model in an object and call it from action using middleware and from prop's component.

All models/logic of your app will be stored in one place along with the store/state object and dispatch function. actions can access the models by calling it from middleware without importing it.

Usage

Register

Register all screens/containers, actions, and logics/models.

Register({Home,Products}, {getProducts}, {fetchProducts});

Middleware

Apply middleware into the store.

createStore(Reducers, Defaults, applyMiddleware(Middleware));

Call a model

Model can be called inside middleware from an action.

// ./src/Models/API.js
export const products = (query, cb) => {
  return fetch('/api/v1/products').then(result => cb(result));
}

// ./src/Redux/Actions/productsActions.js
export const getProducts = (query) => {	
  // Middleware
  return (store) => {
    /**
    * Get Products and Dispatch,
    * this "products" function is coming from a model
    */
    return store.products(query, results => store.dispatch({
      type: 'GET_PRODUCTS',
      payload: results
    }))
  };
};

Call a logic

Call a logic inside a component with argument.

// ./src/Models/Calculate.js
export const calculate = (someArg) => ({
  add: (num1, num2) => {
    return num1 + num2;
  },
})

// ./src/Screens/Products.js
class Products extends React.Component {
  render() {
    const cal = this.props.calculate('someArg');
    return(
      <div>
        {cal.add(465, 1526)}
      </div>
    );
  }
}

Map state to props

Map state through static class property to component props.

// ./src/Screens/Products.js
class Products extends React.Component {
  static map = {
    // A reducer's name
    products: [
      // A state and can be called like this {this.props.items}
      'items'
    ]
  };
  render() {
    return(
      <ul>
        {this.props.items.map((item) => (
          <li>{item.title}</li>
        ))}
      </ul>
    )
  }
}

Inherit parent props

Get props from parent component or even set a state/force update to parent component from child component

// ./src/Components/Products.js
import React from 'react'
import {Inherit} from 'redux-stored'

/**
 * Export images
 */
export default Inherit((props) => {
  const cal = props.calculate('someArg')

  console.log(cal.add(465, 1526))
  return(
    <ul>
      {props.items.map((item) => (
        <li>{item.title}</li>
      ))}
    </ul>
  )
})

Example

See example at https://github.com/coderstage/redux-stored-sample

Change Log

Semantic Versioning

License

MIT