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

@rplx/core

v0.2.1

Published

A re-frame inspired state management library for TypeScript

Readme

@rplx/core

A re-frame inspired state management library for TypeScript.

Installation

npm install @rplx/core

Usage

import { createStore } from '@rplx/core'

// Define your state
interface AppState {
  count: number
}

// Define your coeffects (optional)
interface AppCoeffects {
  uuid: string
  now: Date
}

// Create store with coeffect providers
const store = createStore<AppState, AppCoeffects>({
  initialState: { count: 0 },
  coeffects: {
    uuid: () => crypto.randomUUID(),
    now: () => new Date()
  }
})

// Register event handlers - fully type-safe!
store.registerEvent('increment', (context, payload) => {
  // context.db is AppState
  // context.uuid is string
  // context.now is Date
  return [
    { count: context.db.count + 1 },
    {} // no effects
  ]
})

// Dispatch events
await store.dispatch('increment')

// Get state
const state = store.getState()

Core Concepts

Events

Events are dispatched to trigger state changes. Each event has a handler that receives the current state (via context) and a payload, and returns a new state and effects.

Coeffects (Context)

Coeffects are the inputs to event handlers. Define your coeffect types and provide functions to compute them:

interface MyCoeffects {
  uuid: string
  now: Date
}

const store = createStore<AppState, MyCoeffects>({
  initialState,
  coeffects: {
    uuid: () => crypto.randomUUID(),
    now: () => new Date()
  }
})

// Handlers get type-safe access
store.registerEvent('create', (context, data) => {
  const { db, uuid, now } = context  // ✅ Fully typed!
  return [newState, effects]
})

Benefits:

  • ✅ Full type safety
  • ✅ Easy to test (mock coeffect providers)
  • ✅ Lazy evaluation

Effects

Effects are side effects that can be triggered by event handlers. Common effects include:

  • dispatch - Dispatch another event
  • dispatch-n - Dispatch multiple events
  • Custom effects (HTTP requests, localStorage, etc.)

Interceptors

Interceptors wrap event handlers to add cross-cutting concerns. They have :before and :after phases that run in opposite order (like middleware):

import { path, debug } from '@rplx/core'

store.registerEventWithInterceptors(
  'update-todo',
  [path(['todos']), debug()],
  handler
)

API

createStore<State, Cofx>(config)

Factory function to create a store instance. Generic over State and Coeffects.

Parameters:

  • config.initialState - Initial application state
  • config.coeffects - Optional coeffect providers
  • config.tracing - Optional tracing configuration

Returns: A store instance with the following methods:

  • registerEventDb<Payload>(eventKey, handler, interceptors?) - Register an event handler that returns state
  • registerEvent<Payload>(eventKey, handler, interceptors?) - Register an event handler that returns effects
  • registerEffect<Config>(effectType, handler) - Register an effect handler
  • dispatch<Payload>(eventKey, payload) - Dispatch an event
  • getState() - Get current state
  • flush() - Flush event queue (for testing)
  • registerSubscription(key, config) - Register a subscription
  • subscribe(key, params, callback) - Subscribe to state changes
  • query(key, params) - Query a subscription once

License

MIT