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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-optimist

v0.1.5

Published

Optimistic UI for React using the new Context API.

Readme

Welcome to React Optimist. A simple API for optimistic UI, using React and taking advantage of the new Context API. Used and maintained by Swipes

Idea

A user clicks on a button, you want to save the new state to a server, but you don't want to show a loader in the meantime. react-optimist let's you easily queue requests in the background while showing the new value. Also known as optimistic ui.

Installation (more options)

$ npm install --save react-optimist

High level

react-optimist consist of two high level API's:

  • OptimistProvider is a react class that needs to be added once, similar to Provider (redux), BrowserRouter (react-router) and so on.
  • withOptimist is a higher-order-component (HOC) that you wrap any class that either needs to access to the optimistic data, or will be creating it (or both :). It injects a prop "optimist" into the wrapped component.
withOptimist(Component) >> this.props.optimist

The optimist object API

The optimist object injected into your components has a simple api: Main API:

optimist.set(options)

Params

  • options object - An option object

| Option | Type | Default value | Description | | --- | --- | --- | --- | | key | string | (required) | A key for the queue (ex: goal-reorder, task-119-complete) | | value | any | (required) | The value trying to be sent to the server and that should be used (optimistic) | | handler | function | (required) | The async handler, (next) => {}, you must call next when done | | serial | bool | false | Run all requests added to this queue, not just the last. | | clearOnError | boolean | true | When you return an error to next, wipe future requests | | debounce (coming soon) | number | 0 (ms) | Postpone the server request with x ms from now | | throttle (coming soon) | number | 0 (ms) | Run server requests every x ms |

optimist.get(key, [fallback])

Retreive the current optimistic value or an optional fallback value.

Params

  • key string - entry for the store
  • fallback any value - value to be used if nothing is in store

Returns: store value or fallback

optimist.setDefaultOptions(options)

This will set default options for future calls to set/get.

Params

  • options object - An option object defining defaults, see optimist.set above for supported props.

optimist.identify(id)

This will prepend id for calls to set/get. Not required to run this first

Params

  • id string - An id to prepend future calls to optimist.set (useful for id of a task/project/etc)

Other projects

Used and maintained by Swipes

  • swiss-react - A CSS-in-js solution with sass-like features and an epic syntax.