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

sugarbush-saga

v1.7.2

Published

Sugarbush is a performance enhancer for your react-redux application by replacing the Redux combinedReducers.

Downloads

40

Readme

Sugarbush-Saga

logo-sm.png

Project Source Code

Sugarbush is a performance enhancer for your react-redux application by replacing the Redux combinedReducers with switchback. Switchback will only run the corresponding reducer that matches the dispatched action type. Please read more about npm sugarbush


Sugarbush-Saga includes saga helper that works with the Sugarbush switchback, confingureAdaptiveStrore, and sbPut (saga effect)

Installation

Minimum Requirements: React: 16.8
npm install sugarbush-saga
yarn add sugarbush-saga

Saga

When dispatching Saga actions, the combinedReducers will process all the reducers. With dispatch from configureAdaptiveStore or adaptiveSagaDispatch this will not occur. Both functions take two parameters. The first parameter, dispatch, of type Redux Dispatch, the second parameter, key, of type string. The key assigned to either method must be unique and is used to bypass Sugarbush's switchback. This unique key must also be assigned to Sugarbush's switchback.

dispatchSaga

import { adpStore } from '../components/App'

export const sagaDispatch = () => adpStore.dispatch('@@GAGA-BYPASS!')

Note: The dispatch is a method of the Sugarbush configureAdaptiveStore. To set up a configureAdaptiveStore please read about sugarbush

adaptiveSagaDispatch

import { store } from '../components/App/store'
import { adaptiveSagaDispatch } from 'sugarbush'

export const sagaAdpDispatch = () => adaptiveSagaDispatch({dispatch: store.dispatch, key: '@@GAGA-BYPASS!', versobe: false })

Note: verbose is optional and is true by default but will be set to false in a production environment.

switchback

The unique saga key assigned to either the dispatchSaga or adaptiveSagaDispatch must also be assigned to switchback. This key will prevent switchback from processing any reducers when a saga action is dispatched.

const reducers = switchback({
    SystemState,
    CounterState,
    StatusState,
  }, {sagaBypass: '@@GAGA-BYPASS!'}
)

Note: To set up switchback please read sugarbush

sbPut

Use the sbPut side effect to run the corresponding reducer with switchback. The sbPut wraps the Saga Put effect and adds the reducer’s key to the effect. The sbPut is first initialized with a key representing the reducer listed in switchback. The sbPut reference takes two parameters. The first is an action type, type string, and payload of any.

import { takeEvery } from 'redux-saga/effects'
import { sbPut } from 'sugarbush'
import { SystemActionEnum } from '../actions/system-actions'

/** Using the sugarbush-saga effect of sbPut to set the key*/
const _put = sbPut('SystemState')

export function* watchFetchSystemSettings() {
  yield takeEvery(SystemActionEnum.FETCH_SYSTEM_THEME, fetchSetSystemTheme)
}

function* fetchSetSystemTheme() {
  /** Using the sugarbush-saga effect of sbPut */
  yield _put(SystemActionEnum.SET_SYSTEM_THEME, 'GREEN')
}


Internally the sbPut creates an action type with a key and calls the Saga Put side effect.

const _action:IAction = ({type: type, payload: payload, key: key})
yield put(_action)

Examples:

License

MIT