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

v3.0.0

Published

Rocketjump your redux! Speed up redux-app development

Downloads

87

Readme

redux-rocketjump

Build Status npm version codecov

Rocketjump your redux! Speed up redux-app development.

A set of tools to speed up the development of a redux based app:

  • generate all you need from and for the state from a single function call, easy to extend, easy to compose.
  • an out of the box way to organize redux folders by functionality instead of type.
  • handy helpers to help you compose functionality.

Quick start

Install

yarn add redux redux-saga reselect redux-rocketjump

Your first rocket jump!

// (1) Define your customary fetching logic
function loadTodosFromApi(params) {
  let myHeaders = new Headers();

  let config = {
    method: 'GET',
    headers: new Headers(),
    body: params
  };

  return fetch('https://myawesomehost/api/posts', config)
    .then(response => response.json())
}

// (2) Import rocketjump (rj for friends)
import { rj } from 'redux-rocketjump'
// Main export
// Here we deal with actions, reducers, selectors and sagas that have been created for us
export const {
  // Actions generated by rj
  actions: {
    // This is the function that triggers our fetching logic
    load: loadTodos,
    // This function stops the asynchronous task started with `load` and clears the state
    unload: unloadTods,
  },
  // Selectors generated by rj
  selectors: {
    // Selector used to get the value returned by our fetching logic, when ready
    getData: getTodos,
    // Selector used to detect if our fetch is pending (i.e. the API call is loading)
    isLoading: isLoading,
    // Selector used to get the error with which the last API call failed (if available)
    getError: getTodsError,
  },
  // The generated reducer
  reducer,
  // The generated saga
  saga,
} = rj({
  // Type of our actions
  type: 'GET_TODOS',
  // Piece of state to put data in
  state 'todos',
  // And our fetching logic
  effect: params => loadTodosFromApi(params),
})()

// (3) And then use it in your main file
import { createStore, compose, applyMiddleware, combineReducers } from 'redux'
import createSagaMiddleware from 'redux-saga'
import { makeAppsReducers, makeAppsSaga } from 'redux-rocketjump'
import * as todos from './todos'

// Merge all our application parts
const APPS = {
  todos
}

// Create root reducer
const rootReducer = combineReducers({
  ...makeAppsReducers(APPS),
})

// Create main saga
const mainSaga = makeAppsSaga(APPS)

// Initialize redux store
const preloadedState = undefined
const sagaMiddleware = createSagaMiddleware()
const store = createStore(
  rootReducer,
  preloadedState,
  compose(
    applyMiddleware(sagaMiddleware),
  )
)

// Start main saga
sagaMiddleware.run(mainSaga)

// Export the created store
export default store

Deep dive

The full documentation with many examples and detailed information is mantained at

https://inmagik.github.io/redux-rocketjump

Be sure to check it out!!

Run example

You can find an example under example, it's a simple REST todo app that uses the great json-server as fake API server.

To run it first clone the repo:

git clone [email protected]:inmagik/redux-rocketjump.git

Then run:

yarn install
yarn run-example