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

juanstate

v1.2.2

Published

Simple state handler for react

Downloads

2

Readme

JuanState

Simple state handler to use with react. It is more of a proof of concept than actual tool. This repo contains an example of how to use JuanState. These are just pre-built react components so no magic here.

Usage

JuanState is a mini state handler based on Redux. It is not intended for big projects. Sense it is based on Redux, it uses the same logic.

WareHouse

Equivalent to a Redux Store. It handles state and receives reducers. Only one store can exist as it is a singleton.

Reducer

A function that receives previous state and an action and returns an action. All reducers must be functions. A WareHouse can only contain one reducer. Combining reducers can be done in several ways. The easiest is using the "combineReducers" function or if you need feedback you can use the Reducer class which contains a combineReducers static function. If debugging is enabled, the static function will print on console useful information. The combineReducers function ignores invalid reducers. Reducers should be pure or else the WareHouse may fail.

Action

Something that changes the state. Actions must be a javascript object with a type attribute. On initializing, the store will pass an action of type "firstAction" to the reducer to initialize the state. Action creators are funtions that return an Action. This is common practice in Redux.

Dispatch()

The Dispatch function sends an Action to the Reducer to change the WareHouse state

combineReducers()

combineReducers receives any number of arguments. If an argument is a valid reducer function, it will create a new function that chains all valid reducer functions passed as arguments. The chain is basically just calling function after function from left to right. If an argument is invalid it is ignored.

inject()

this function is equivalent to Redux connect(). It receives a component and an injection function. The injection function must receive one parameter and it will receive the WareHouse state. This function must return what piece of state wants to be injected into the component. There is an alternative component version of this.

getState()

returns the current WareHouse state.

hasStateChanged()

returns whether state has changed or not.

getStore()

returns the WareHouse instance.