Socket
Socket
Sign inDemoInstall

redux-profiler

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    redux-profiler

A Redux store enhancer which uses User Timing API to profile redux actions and time spent on notifying store listeners


Version published
Weekly downloads
1.3K
increased by58.52%
Maintainers
1
Install size
18.2 kB
Created
Weekly downloads
 

Readme

Source

redux-profiler

NPM version NPM downloads MIT License Coverage

A Redux store enhancer which uses User Timing API to profile Redux actions and time spent on notifying store listeners

How to install

npm install redux-profiler --save

Usage

import { createStore } from 'redux'
import profileStore from 'redux-profiler'

function todos(state = [], action) {
    switch (action.type) {
        case 'ADD_TODO':
            return state.concat([action.text])
        default:
            return state
    }
}
​
const store = createStore(todos, ['Use Redux'], profileStore())

You can also combine it with Redux middleware:

import { createStore, compose } from 'redux'
import { thunk } from 'redux-thunk'
import profileStore from 'redux-profiler'

function todos(state = [], action) {
    switch (action.type) {
        case 'ADD_TODO':
            return state.concat([action.text])
        default:
            return state
    }
}
​
const store = createStore(
    todos,
    ['Use Redux'],
    compose(
        profileStore(),
        thunk
    )
)

or if you have multiple middlewares:

import { createStore, applyMiddleware, compose } from 'redux'
import { thunk } from 'redux-thunk'
import profileStore from 'redux-profiler'

function todos(state = [], action) {
    switch (action.type) {
        case 'ADD_TODO':
            return state.concat([action.text])
        default:
            return state
    }
}

/**
 * Logs all actions and states after they are dispatched.
 */
const logger = store => next => action => {
    console.group(action.type)
    console.info('dispatching', action)
    let result = next(action)
    console.log('next state', store.getState())
    console.groupEnd()
    return result
}
​
const store = createStore(
    todos,
    ['Use Redux'],
    compose(
        profileStore(),
        applyMiddleware(
            thunk,
            logger
        )
    )
)

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Keywords

FAQs

Last updated on 10 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc