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

storeheaven

v1.0.5

Published

A Lightweight Persistent State Management Library

Readme

storeheaven

storeheaven is a lightweight, customizable state management library for React Native applications. It simplifies the process of persisting and managing application state across components for react native.

Features

  • Persistent State Management: Automatically save and load state.
  • Custom Blacklisting: Exclude specific states from persistence.
  • Reactivity: Subscribe to state changes and update UI dynamically.
  • Easy Integration: Minimal setup and flexible API.

Installation

Install storeheaven via npm:

npm install storeheaven

or

yarn add storeheaven

Usage

1. Setting Up a Store

Create a store folder inside store folder create demoStore.js file

(note you can provide desired name for store file)

import { createStore } from "storeheaven";

const demoInitialState = {
  isDemoMode: false,
  customStep: 0,
  apiData: null,
};

// Create a store
export const demoStore = createStore("demo", demoInitialState);

2. Initializing All Stores

Initialize all stores in your application using initializeAllStores create index.js in your store folder:

import { demoStore } from "./demoStore";
import { detailsStore } from "./detailsStore";

// Function to initialize all stores
export const initializeAllStores = async () => {
  const stores = [demoStore, detailsStore]; // provide created store file name to this stores array
  await Promise.all(stores.map((store) => store.initializeStore()));
};

3. Integrating in the App Entry Point

Use the initializeAllStores function in your app's entry point to set up the stores before rendering your app:

import React, { useEffect, useState } from "react";
import { ActivityIndicator, View, StyleSheet } from "react-native";
import { initializeAllStores } from "./store";

const App = () => {
  const [isInitialized, setIsInitialized] = useState(false);

  useEffect(() => {
    const initStores = async () => {
      try {
        await initializeAllStores();
        setIsInitialized(true);
      } catch (error) {
        console.error("Error initializing stores:", error);
      }
    };

    initStores();
  }, []);

  if (!isInitialized) {
    return (
      <View style={styles.container}>
        <ActivityIndicator size="large" />
      </View>
    );
  }

  return <YourAppNavigator />;
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default App;

4. Using the Store in Components

Access and update the store state using the useStoreState hook:

import React from "react";
import { View, Text, Button, StyleSheet } from "react-native";
import { useStoreState } from "storeheaven";
import { demoStore } from "./demoStore";

const DemoComponent = () => {
  const [isDemoMode, setDemoMode] = useStoreState(demoStore, "isDemoMode");
  const [customStep, setCustomStep] = useStoreState(demoStore, "customStep");

  return (
    <View style={styles.container}>
      <Text style={styles.text}>Demo Mode: {isDemoMode ? "ON" : "OFF"}</Text>
      <Button
        title={isDemoMode ? "Turn Off Demo Mode" : "Turn On Demo Mode"}
        onPress={() => setDemoMode(!isDemoMode)}
      />

      <Text style={styles.text}>Custom Step: {customStep}</Text>
      <Button title="Next Step" onPress={() => setCustomStep(customStep + 1)} />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    padding: 20,
    backgroundColor: "#fff",
  },
  text: {
    fontSize: 16,
    marginBottom: 10,
  },
});

export default DemoComponent;

API Reference

createStore(name, initialState)

  • name (string): Unique key for the store.
  • initialState (object): The initial state of the store.

Creates a store with the provided name and initialState.


initializeStore()

Initializes the store and loads its state from AsyncStorage.


getState(key)

  • key (string, optional): Fetches the value of a specific key in the state. If no key is provided, returns the entire state.

setState(updates)

  • updates (object): Partial updates to the store state.

subscribe(listener)

  • listener (function): A function that will be called when the state changes. Returns an unsubscribe function to stop listening for changes.

useStoreState(store, key)

React hook for accessing and updating store state in functional components.

Contributing

Contributions are welcome! Please fork this repository, make your changes, and submit a pull request.

License

This project is licensed under the MIT License.