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

unstated-logger

v1.0.1

Published

Debug your [unstated](https://github.com/jamiebuilds/unstated) containers easily with `unstated-logger` who adds support for redux dev tools. The integration with the `redux dev tools` plugin makes jumping from different state in time possible (time trave

Downloads

3

Readme

Unstated logger

Debug your unstated containers easily with unstated-logger who adds support for redux dev tools. The integration with the redux dev tools plugin makes jumping from different state in time possible (time travel).

Install

npm install --save unstated-logger

# or

yarn install --save unstated-logger

Usage

In the root of your app, import unstated-logger`:

import Logger from 'unstated-logger';

Logger.start();

// ... Yor component code as always

Integration with redux dev tools

Install the browser plugin available in redux dev tools, follow the instructions and you are ready to go. This plugin makes jumping from different state in time possible (time travel).

Once the plugin is installed we need to communicate actions to it, the changes you need to do are in the Container classes. You must give an instance name and notify actions using the same payload for state changes.

In the example bellow we assign the Counter name for the redux dev tools widget and notify about INCREMENT and DECREMENT actions, using the reserved keyword `__action, so we can track this in the redux dev tools panel using the web browser.

// @flow
import { Container } from 'unstated';

type CounterState = {
  count: number
};

class CounterContainer extends Container<CounterState> {
  state = {
    count: 0
  };

  // Widget name to show in the redux devl tools panel
  name = 'Counter';

  increment() {
    this.setState({
      count: this.state.count + 1,
      __action: 'INCREMENT'
    });
  }

  decrement() {
    this.setState({
      count: this.state.count - 1,
      __action: 'DECREMENT'
    });
  }
}

API

After logger get staterted it exposes some methods and config options so you can explore the containers or their states in the Dev Tools panel.

// Get all the states in the store
const store = Logger.store();
// Do something with the store

// Get all containers
const containers = Logger.containers();
// Do something with the containers

// Output all the states
Logger.print();

The logger accepts the following config options:

Config

const config = {
  collapsed: true,
  detailed: false,
};

Logger.config(config);

collapsed

Type: boolean Default: false

Collapse the state change logs in the Dev Tools console.

detailed

Type: boolean Default: true

Log detailed state changes (Added, deleted and changed).

ignore

Type: array Default: ['JUMP_TO_STATE', 'JUMP_TO_ACTION']

Actions to be ignored in the redux Dev Tools notifications.

details

Type: array Default: ['added', 'updated', 'deleted']

The log level detail to show up in the Dev Tools console. Allowed values added, updated and deleted.