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

rxdeep

v0.2.1

Published

RxJS deep state management

Downloads

48

Readme

banner

npm i rxdeep

RxDeep provides fast and precise reactive state management in JavaScript / TypeScript, in a flexible and unopinionated manner. Make changes at any point on the state tree, and listen to changes on particular parts of your tree, with a precision emission system that ensures you only get values when something has truly changed.

👉 Read the docs for more info.

Example Usage

▷ Create a state object:

import { state } from 'rxdeep';

const s = state([ { name: 'John' }, { name: 'Jack' }, { name: 'Jill' } ]);

▷ Listen to changes on 'name' property of index 1 on the list:

s.sub(1).sub('name').subscribe(console.log);     // --> logs `Jack`

▷ You can modify the top-level state:

s.value = [ { name: 'Julia' }, ...state.value ]; // --> logs `John`, since `John` is index 1 now

▷ Or mid-level states:

s.sub(1).value = { name: 'Josef' };              // --> logs `Josef`

▷ Or another sub-state with the same address:

s.sub(1).sub('name').value = 'Jafet';            // --> logs `Jafet`

RxJS interop:

import { interval } from 'rxjs';
import { map } from 'rxjs/operators';

interval(1000)
.pipe(map(i => ({ name: `Jarvis #${i}`})))
.subscribe(s.sub(1));                            // --> logs `Jarvis #0`, `Jarvis #1`, `Jarvis #2`, ...
import { debounceTime } from 'rxjs/operators';

s.sub(1).pipe(debounceTime(1000)).subscribe(console.log); // --> debounces changes for 1 second

👉 Learn more.

UI Frameworks

RxDeep is completely framework agnostic. It is also by no means limited to use on frontend (though that is understandably most common use-case). Due to it being based on RxJS and having high interop with it, you can easily use it anywhere that you can use RxJS.

Use with React

Use with Angular

Use with Vue.js

Because of its precise change emissions, using RxDeep in conjuction with popular UI frameworks should actually speed them up (since it results in less burden for the underlying change detection mechanisms of these frameworks).

👉 Learn more.

Prior Work

RxDeep is not necessarily a replacement / alternative to many existing state management libraries. Typically these libraries provide / enforce some particular patterns which might or might not be useful to a particular application, while RxDeep avoids any such constraints, instead focusing on providing a performant and precise reactive state tree.

Here is how RxDeep compares / relates to some of the most well-known state management libraries:

Redux

Redux is a particular state management pattern (and a library providing it), while RxDeep is not. You actually can implement the Redux pattern using RxDeep state-trees if you so choose to.

Redux as a library doesn't have a concept of precision, i.e. you cannot listen to changes on a particular part of the state-tree in isolation. This is simply because Redux was designed primarily to be coupled with React, and so delegates figuring actual scope of changes to its Virtual DOM mechanism.

In contrast, precision is the main feature of RxDeep, which means surgically precise changes reach the final UI layer. With RxDeep the scope of each change is computed much more efficiently on the data layer (on the state-tree itself), instead of it being passed down to some external underlying library.

MobX

RxDeep and MobX share some core design philosophies in terms of being unopinionated reactive state management solutions. The main difference is MobX's implicit approach for automatically deducing state / expression dependencies, while RxDeep relies on the power of RxJS for explicitly defining / manipulating streams.

This brings much more fine grained control and extensibility, at the expense of face-value learnability (as RxJS does seem more complicated to newcomers). However in practice MobX syntax (e.g. computed values), doesn't differ much from the equivalent RxJS syntax (e.g. the map pipe). In fact, MobX's implicit deduction approach raises implicit constraints and considerations, while the explicit approach of RxJS avoids that, and the actual added complexity of RxJS kicks in for operations beyond the scope of MobX.

Focal

Amongst mentioned libraries, RxDeep shares most concepts and ideas with Focal. Focal, however, is specifically designed specifically to work with React, while RxDeep is completely framework agnostic. This also means that similar to Redux, precision is not a priority for Focal, while it is the main focus of RxDeep.

Build Status Code Coverage Minzipped Size NPM Version Code Quality License