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-action-log

v2.1.0

Published

Redux store enhancer for recording action history.

Downloads

7,475

Readme

redux-action-log

GitHub license npm version CircleCI Status Greenkeeper badge

This project is a redux store enhancer which allows you to record the redux action history and access it. It can be configured to have a maximum number of actions to keep in the history. Early actions will be removed from the history, and the redux state of the beginning of the history will be recorded.

Usage

import {createStore} from 'redux';
import {createActionLog} from 'redux-action-log';

import myReducer from './reducer';

const actionLog = createActionLog({limit: 100});
const store = createStore(myReducer, undefined, actionLog.enhancer);

// ...

const log = actionLog.getLog();
// {
//   initialState: undefined,
//   skipped: 0,
//   actions: [
//     {action: {type: 'ADD', payload: 3}, timestamp: 1469604366218},
//     {action: {type: 'ADD', payload: 5}, timestamp: 1469604424293}
//   ]
// }

If you are using other store enhancers such as applyMiddleware, then you'll need to compose actionLog's enhancer. Make sure to place it last to let it see actions generated by previous enhancers:

import {compose, createStore, applyMiddleware} from 'redux';
import {createActionLog} from 'redux-action-log';

import myReducer from './reducer';
import someMiddleware from './someMiddleware';

const actionLog = createActionLog({limit: 100});

let enhancer = applyMiddleware(someMiddleware);
enhancer = compose(enhancer, actionLog.enhancer);

const store = createStore(myReducer, undefined, enhancer);

API

This module exports the createActionLog(options) function. The options object may have the following properties:

  • limit: Soft limit to the number of actions recorded. May be set to null to mean no limit. Defaults to 200.
  • snapshotInterval: When this many actions pass, a checkpoint containing a reference to the current state is made. A higher number means fewer checkpoints will be kept in memory, but it means that the log must go on longer before being culled. May be set to null to mean no checkpoints should be made (this is only sensible when no limit is used too). Defaults to 20.

The function returns an ActionLog object with the following properties:

  • enhancer: Pass this to createStore once.
  • getLog(): Returns the object {initialState, skipped, actions}.
  • setLimit(n): Change the limit option. This will cull the action log if necessary.
  • clear: Completely cull the current log. It's similar to setting limit to 0 and then back to its previous value.

Types

Both TypeScript and Flow type definitions for this module are included! The type definitions won't require any configuration to use.