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 🙏

© 2026 – Pkg Stats / Ryan Hefner

expo-waterfall-persist

v0.0.1

Published

expo-waterfall-persist is A persistent state storage extension for react-waterfall running in Expo

Readme

expo-waterfall-persist

Run the demo on Expo.io / Clone the demo

expo-waterfall-persist is persistent storage middleware for react-waterfall, for Expo apps.

demo

Installation

npm install expo-waterfall-persist
npm install git://github.com/benallfree/react-waterfall.git#master

Note: a fork of react-waterfall is required temporarily. See Discussion below.

Usage

import { persist } from 'expo-waterfall-persist'
const { Provider } = createStore(config, [persist])

export default () => <Provider onSaved={() => console.log('saved')} />

The magic is in the middleware. By supplying the persist middleware to createStore, you enable state persistance and status callbacks on the Provider.

Provider accepts several new props when the persist middleware is installed:

Props:

fileUri (default ${FileSystem.documentDirectory}/state.json) The path to the file used to persist state. See Expo FileSystem for details.

debounce (default {wait: 250, maxWait: 1000}) Debounce is used to prevent state from saving too rapidly. By default, it will wait at leaste 250ms before saving, but it will save at least every 1s if things have changed.

onLoaded({ state, fileUri }) Called when state has been restored from persistant storage.

onSaved({state, fileUri}) Called when state is saved to persistent storage.

onSaveError({ error, fileUri }) Critically bad news. Called when state fails to save to persistent storage.

onLoadError({ error, fileUri }) Fairly bad news. Called when state fails to load from persistant storage due to some error other than 'file not found'. Default state used instead.

onVersionMismatch({ oldState, newVersion }) Harmless. Called when persisted state version does not match current version specified in config, and the default state is used instead. State versioning is an optional but useful feature if you issue an app update that makes previously persisted states incompatible.

onPersistedStateNotFound({ fileUri }) Harmless. Called when persistent state is not present. Harmless, uses default state.

More Complete Example

See expo-waterfall-persist-demo for a working example.

import React from 'react'
import { Text, View } from 'react-native'
import createStore from 'react-waterfall'
import { persist } from 'expo-waterfall-persist'

const config = {
  initialState: { version: 1, tick: 0 },
  actionsCreators: {
    tick: ({ tick }) => ({
      tick: tick + 1
    })
  }
}

// Here's the magic! The `persist` middleware
const { Provider, actions, connect } = createStore(config, [persist])

const ShowTick = connect(({ tick }) => ({ tick }))(({ tick }) => (
  <Text>{tick}</Text>
))

export default class App extends React.Component {
  componentWillMount() {
    setInterval(() => {
      actions.tick()
    }, 50)
  }

  handleStateSaved = state => {
    console.log('The state was persisted.', state)
  }

  render() {
    return (
      <View>
        <Provider onSaved={this.handleStateSaved}>
          <ShowTick />
        </Provider>
      </View>
    )
  }
}

Discussion

Making this package work has required a temporary fork of react-waterfall. I needed to update the middleware strategy so that middleware was capable of modifying createStore initializers as well as setting state of the store without forcing the user to create an action or polluting the actionsCreators structure.

Due to the asynchronous nature of loading/saving persistent state in the Expo filesystem, this package will not render the children of Provider until state has resolved either to the persisted state or the default state if persisted state fails to load.