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

lbrx

v0.4.0-alpha

Published

State Manager for JS Apps

Downloads

9

Readme

LbrX - alpha version

This is an object oriented State Manager that's build for JavaScript applications that's based on RxJs. The api for querying the data is very similar to .Net EF LINQ but with observables. State updates can also be achieved with partial objects and we will merge the objects for you. Object instance preservation guaranteed if you're working with classes or dates. Unlinked object references guaranteed even with deep nested objects, no changes will apply to your state unintentionally. Two way data flow with no boilerplate code! We also support Redux DevTools for easier state debugging.

Development progress

  • [x] Single object store
  • [x] Class support
  • [x] Local or session storage configuration per store
  • [x] Reset-able stores support
  • [x] Object compare configuration per store support for better performance with very large objects
  • [x] Store hooks
  • [x] Redux DevTools one way support
  • [x] Redux DevTools both ways support
  • [x] Deep nested objects support
  • [x] Global default store configurations
  • [x] Async initialization support (Promise and Observable)
  • [x] Serialization and denationalization configuration for browser storage
  • [x] NgZone Support
  • [x] ES5 support
  • [x] Multi platform support, including Node.JS
  • [x] LbrX utility functions available for import
  • [x] Store pause api
  • [x] Store destroy api
  • [x] Advanced store config that allows methods override like objectClone, objectCompare, etc.
  • [x] Select with string literals
  • [x] Full spec coverage of the above
  • [ ] List Store - wip
  • [ ] Full spec coverage of the above
  • [ ] Playground
  • [ ] Full documentation

Important Notice

  • Added support for moment.js.
  • LbrX utility functions and types are now available via import { ... } from 'lbrx/utils'.
  • storeName.select() is removed. Use: storeName.select$().
  • Global error store has bee removed.
  • Hook's interfaces have been removed. Now you can just override the methods in the inheritor class.
  • LbrXManager should now be imported from lbrx/core.
  • DevtoolsOptions should now be imported from lbrx/dev-tools.

Dependencies

  • RxJS 6.5.4 or higher.

Installation

npm i lbrx rxjs

CDN

| URL | ES | Minified | | --------------------------------------------------------------------------- | ------ | -------- | | https://cdn.jsdelivr.net/npm/[email protected]/bundles/lbrx.umd.js | ES2015 | No | | https://cdn.jsdelivr.net/npm/[email protected]/bundles/lbrx.umd.min.js | ES2015 | Yes | | https://cdn.jsdelivr.net/npm/[email protected]/bundles/lbrx.umd.es5.js | ES5 | No | | https://cdn.jsdelivr.net/npm/[email protected]/bundles/lbrx.umd.es5.min.js | ES5 | Yes |

Example

Step 1: Initialization

import { LbrXManager, StoreConfig, Store, Storages } from "lbrx";

const PROD_MODE = false;
if (PROD_MODE) LbrXManager.enableProdMode();
LbrXManager.initializeDevTools();

class Address {
  place: string | null = null;
}

class User {
  firstName: string | null = null;
  lastName: string | null = null;
  address: Address | null = null;
}

function createLeon(): User {
  return Object.assign(new User(), {
    firstName: "Leon",
    address: Object.assign(new Address(), {
      place: "Hell of a place",
    }),
  });
}

Step 2: Create Store

@StoreConfig({
  name: "LEON-STORE",
  objectCompareType: ObjectCompareTypes.advanced,
  isResettable: true,
  storageType: Storages.session,
  storageDebounceTime: 500,
})
class UserStore extends Store<User> {
  constructor() {
    super(createLeon());
  }
}

const userStore = new UserStore();

Step 3: Subscribe to changes

userStore.select$().subscribe((x) => console.log(x));
userStore
  .select$((state) => state.firstName)
  .subscribe((x) => console.log("firstName: " + x));
userStore
  .select$((state) => state.lastName)
  .subscribe((x) => console.log("lastName: " + x));
userStore
  .select$((state) => state.address?.place)
  .subscribe((x) => console.log("address: " + x));

// User {firstName: "Leon", lastName: null, address: Address}
// firstName: Leon
// lastName: null
// address: Hell of a place

Step 4: Update Store

Pay attention to the values that haven't been changed. They won't trigger their subscribers, thus preventing unnecessary performance hit.

setTimeout(() => {
  userStore.update({
    firstName: "Some other name",
    lastName: "My first lastName",
  });
}, 200);

// User {firstName: "Some other name", lastName: "My first lastName", address: Address}
// firstName: Some other name
// lastName: My first lastName

setTimeout(() => {
  userStore.update({
    firstName: "Some other name",
    lastName: "My second lastName",
    address: {
      place: "Some other place",
    },
  });
}, 500);

// User {firstName: "Some other name", lastName: "My second lastName", address: Address}
// lastName: My second lastName
// address: Some other place

setTimeout(() => {
  userStore.reset();
}, 500);

// User {firstName: "Leon", lastName: null, address: Address}
// firstName: Leon
// lastName: null
// address: Hell of a place

setTimeout(() => {
  userStore.reset();
}, 550);

// NOTHING will print ( because the state didn't change. )

Step 5: Debug using Redux DevTools

ReduxDevTools

Browser Support

  • All current browsers (major versions from the last 2 years) are supported.
  • Node.JS support.
  • Source files are included in 'node_modules\lbrx\src'.
  • UMD bundles* are included in 'node_modules\lbrx\bundles'.
  • IE11** ES5 syntax support.

* Both ES5 and ES2015 UMD bundles are included and both have minified and non minified versions. In all bundles the global would be lbrx.

** For IE11 you may need additional polyfills but if you're using a framework, they may already be included.

Licence