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

rxbox

v0.7.1

Published

state container for Angular

Downloads

941

Readme

CircleCI

Simple state container for Angular application

RXBox let's you handle your Application state in one place. You retain the responsibility for updating the state to your app. It gives you an easy API to deal with your app's state.

Getting started

Install rxbox using npm.

npm install rxbox --save

Add RXBox to your main NgModule providers array

providers: [
  { provide: RXBox, useClass: RXBox }
]

import it into a component

import { RXBox } from 'rxbox'

Inject it to your constructor

 constructor(
        private store: RXBox,
    ) {}

Now you can start interacting with the store from your component.

API

assignState(stateChanges)

assignState push data to the store

*Note if you have multiple subscribers open, and you are 'assignState' inside one of the callback, it is possible that you will prevent one of the subscribers to run. Because the 'watch' and 'select' methods run only if the key that you subscribe to is in the last change of the store. Therefore if you are not sure, it is best to use 'assignStateAsync' over 'assignState'

 this.store.assignState({ foo: bar })

assignStateAsync(stateChanges): Promise

assignStateAsync push data to the store only after all I/O events in the current snapshot are processed

 await this.store.assignStateAsync({ foo: bar })

clearState()

clearState will completely remove the current state and will replace it with empty object

 this.store.clearState()

getState(passByReference [optional] )

Return copy of current app state object. if not sending true to passByReference it will return a copy of the state

 this.store.getState()

select(key, subscriberName [optional], passByReference [optional] )

Doing exactly the same thing as watch but also return the previous value if any. Note that if the current value in the store is new, watch will also behave the same way as select and will fire instantly the data

You can add name to subscriber (subscriberName) and then see if they open from console with RXBox.subscribers

this.store.select('foo').subscribe(
    val => {
        console.log('change in foo value',  val)
    }
)
// nested key watch
this.store.select('foo.bar').subscribe(
    val => {
        console.log('change in bar value',  val)
    }
)

debug

If you want to use the state history feature, you have to first set debug to true

this.store.debug = true

sessionStorage

save the store to the sessionStorage

this.store.saveToSessionStorage = true
this.store.saveToSessionStorage = true

localStorage

save the store to the localStorage

this.store.saveToLocalStorage = true

Get data from the storage

to restore from localStorage or from sessionStorage use getStoreFromSessionStorage() or getStoreFromLocalStorage() don't try to get the value from the storage yourself without the getters (the storage also store metadata)

getHistory()

Show the history of the state (first you have to set debug to true)

this.store.getHistory()

clearHistory()

Remove all state history

this.store.clearHistory()