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 🙏

© 2024 – Pkg Stats / Ryan Hefner

driftrx

v1.0.7

Published

DriftRx is a lightweight library for managing and observing streams of data in JavaScript and TypeScript applications. It provides a simple and intuitive API for creating and dispatching actions, registering side effects, and observing changes to data str

Downloads

18

Readme

DriftRx

DriftRx is a TypeScript library for managing application state using the observer pattern.

It provides an easy-to-use API for creating observable stores and subscribing to changes in the state of those stores. DriftRx is designed to be framework-agnostic, so it can be used in any JavaScript or TypeScript project.

Features

  • Simple and intuitive API for managing state
  • Lightweight and easy to use
  • Supports TypeScript out of the box
  • Framework-agnostic

Installation

You can install driftRx via npm:

npm install driftRx

Here's an example of how to use driftRx:

import { StreamStore } from "driftRx";

const store = new StreamStore();

store.createAction("counter", 0);

const counter$ = store.action("counter");

const subscription = counter$.subscribe((value) => console.log(value));

store.dispatch("counter", 1);
store.dispatch("counter", 2);
store.dispatch("counter", 3);

subscription.unsubscribe();

API

StreamStore

The main class provided by driftRx. It manages the creation, observation, and dispatching of data to action streams.

createAction(name: string, initialData: any): void

Creates a new action stream with the given name and initial data.

createEffect<T>(actionName: string, effect: (actionData: T, store: StreamStore) => void): void

Registers a side effect that should be executed whenever a given action is dispatched.

action<T>(name: string): Observable<T>

Gets an observable for the given action stream.

dispatch<T>(name: string, payload: T): void

Dispatches data to the given action stream.

destroyAction(name: string): void

Destroys the given action stream and all related data in the store.

storeEvents$: Observable<StreamStoreEvent>

An observable for stream store events.

StreamStoreEvent

An object representing a stream store event.

type: StreamStoreEventName

The type of the stream store event.

data: StreamStoreEventData

The data related to the stream store event.

StreamStoreEventData

An object representing the data related to a stream store event.

name: string

A string representing the name of the action stream related to the event.

current?: any

The current data for the action stream related to the event.

changed?: any

The changed data for the action stream related to the event.

Testing

You can run the tests for driftRx by running the following command:

npm run test

Contributing

Contributions to DriftRx are always welcome! If you find a bug or would like to suggest a new feature, please open an issue on the GitHub repository.

If you would like to contribute code to the project, please fork the repository and submit a pull request with your changes. Please ensure that your code follows the contributing guidelines and passes all tests before submitting.

License

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