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

@rbxts/cascade

v0.0.2

Published

Simple lightweight state library for Roblox-TS

Downloads

7

Readme

Cascade - Simple State Management for Roblox-TS

Cascade is a lightweight state management library for Roblox-TS, designed to make handling state in your Roblox games simple and efficient. By focusing on the concept of "truth" and states that depend on it, Cascade ensures your game's state is always synchronized and easy to manage.

Features

  • Simple API: Easy to understand and use, even for beginners.
  • Lightweight: Does not burden your game with unnecessary complexity.
  • Efficient State Management: Keeps your game's state synchronized effortlessly.

Installation

  1. Install the package via npm:
npm install @rbxts/cascade
  1. Include it in your Roblox-TS project:
import { Cascade } from "@rbxts/cascade";

Quick Start

Defining the truth and state

interface PlayerTruth {
	health: number;
	experience: number;
}

interface PlayerState extends PlayerTruth {
	isAlive: boolean;
	level: number;
}

Creating a Cascade store

const initialTruth: PlayerTruth = {
	health: 100,
	experience: 0,
}

const reducer = (state: PlayerTruth): PlayerState => {
	return {
		...state,
		isAlive: state.health > 0,
		level: math.floor(state.experience / 100),
	};
};

const actions = {
    heal(state: PlayerTruth, amount: number) {
        state.health += amount;
    }
	takeDamage(state: PlayerTruth, amount: number) {
		state.health -= amount;
	},
	addExp(state: PlayerTruth, amount: number) {
		state.experience += amount;
	},
    levelUp(state: PlayerTruth) {
        state.experience += 100;
        state.health = 100;
    }
};

const store = new Cascade(initialTruth, reducer, actions);

Accessing state

const state = store.getState();
print(state.isAlive);
print(state.level);

Modifying state through actions

store.takeDamage(20);
store.addExp(50);

Observing state changes

const aliveSelector = createSelector((state: PlayerState) => state.isAlive);
const levelUpSelector = createSelector((state: PlayerState) => (state), (previous, current) => previous.level !== current.level);

store.observe(aliveSelector, (isAlive) => {
    if (!isAlive) {
        print("Player died!");
    }
});
store.observe(levelUpSelector, (state) => {
    print(`Player reached level ${state.level}!`);
});

Subscribing to all state changes

store.subscribe((state) => {
    print(`Player health: ${state.health}`);
    print(`Player level: ${state.level}`);
});

One-time observations and subscriptions

store.observeOnce(aliveSelector, (isAlive) => {
    if (!isAlive) {
        print("Player died for the first time!");
    }
});

store.subscribeOnce((state) => {
    print(`Player reached level ${state.level} for the first time!`);
});

Cleanup

store.destroy();

API Reference

Cascade<T, S, A>

  • constructor(truth: T, reducer: (state: T) => S, actions: A)
  • getState(): S - Returns the current state.
  • getTruth(): T - Returns the current truth.
  • observe<U>(selector: Selector<U>, callback: (value: U) => void): RBXScriptConnection - Observes changes to a specific part of the state.
  • subscribe(callback: (state: S) => void): RBXScriptConnection - Subscribes to all state changes.
  • observeOnce<U>(selector: Selector<U>, callback: (value: U) => void): RBXScriptConnection - Observes changes to a specific part of the state once.
  • subscribeOnce(callback: (state: S) => void): RBXScriptConnection - Subscribes to all state changes once.
  • destroy(): void - Destroys the store and cleans up all subscriptions.

createSelector<State, U>(selector: (state: State) => U, didChange?: (previous: U, current: U, lastState: State, newState: State) => boolean): Selector<U>

Creates a selector for observing a specific part of the state.

License

Cascade is released under the MIT License. See LICENSE for more information.