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

dynn-redux

v1.0.1

Published

Redux helpers, middleware, store enhancers and other goodies

Downloads

5

Readme

dynn-redux

Redux helpers, middleware, enhancers and other goodies

install instructions

  • Make sure you got Node.js and NPM installed
  • Navigate to your project directory with cd
  • Run npm install dynn-redux
  • Pet yourself on your shoulder, you just installed dynn-redux

usage instructions

Best way to explain is some hot example code.

// lets import our goodies, if you are an es6 hero you know what to do
const { createActionHandlers, createActionCreator, createReducer, createPromise, promiseMiddleware } = require('dynn-redux')

// obviously we are going to import the Redux as well
const { createStore, applyMiddleware } = require('redux')

// I got a secret crush on Ramda, don't tell
const { assoc } = require('ramda')

// time to define some action creators
// first the sync ones
const add = createActionCreator((value) => ({ type: 'ADD', payload: value}))
const error = createActionCreator((error) => ({ type: 'ERROR', payload: error}))

// also let's get funky we are going to setup an async action creator
const addAsync = createActionCreator((value) => ({
  type: 'ADD_ASYNC',
  // yeah baby, we have a promise in our payload 
  payload: createPromise((resolve, reject) => {
    // lets use setTimeout to fully live the async dream
    setTimeout(() => {
      // a little bit of logic
      if (typeof value === number) {
        // okay we got what we wanted, now resolve with an other action
        resolve(add(value))
      } else {
        // we didn't got a number... reject with an appropiate action
        reject(error('we should have gotten a number instead'))
      }
    // 1 second delay  
    }, 1000)
  })
})

// we cant do shit without an fancy reducer, here we go!
const actionHandler = combineActionHandlers(
  // yeah we are doing it, we are going to combine multiple actionHandlers
  // actionHandlers take an actionType and a reduce function
  createActionHandler('ADD', (state, action) => assoc('counter', state.counter + action.payload, state)),
  // we are going to take care of the ERROR actiontype as well
  createActionHandler('ERROR', (state, action) => assoc('error', action.payload, state))
)

// we are almost ready to create the reuder, first lets declare some initial state
const initState = {counter: 0, error: false}

// rise reducer, RISE! 
const reducer = createReducer(initState, actionHandler)

// ok, we have all the pieces, lets boot up the store
const store = createStore(reducer, initState, applyMiddleware(promiseMiddleware))

// the state within the store should look like this now
{ counter: 0, error: false }

// just use your usual way of dispatching on your store, as that is with react-redux or something more exotic
store.dispatch(addAsync(1))

// after 1 second your state will look like
{ counter: 1, error: false }

// if we now mess up some way like this
store.dispatch(addAsync('Messing up'))

// after another second our state in our store would look like this here
{ counter: 1, error: 'we should have gotten a number instead' }

testing

  • clone the repo
  • cd into it
  • run npm test, tests should automaticly rerun on file changes

contributing, requests, questions, everything else

I would love to see your issue or pull request.

contributors

Frank van Vuuren [email protected]

Uses