Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bripkens/rxstore

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bripkens/rxstore

RxJS based stores for highly reactive UIs

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

rxstore

For more information about the rxstore project, refer to the root-readme of the rxstore project.

Store implementation.

Installation

npm install --save @bripkens/rxstore
–or–
yarn add @bripkens/rxstore

Usage

rxstore differentiates between stores and tracking stores.

  • stores: Hold state and can be directly influenced by actions. These are the classical Flux architecture stores.
  • tracking stores: Tracking stores are lightweight wrappers around existing RxJS observables. Tracking stores exist to maintain store contracts and to expose the last emitted value for development tools.

Creating a store

import {createStore} from '@bripkens/rxstore';

const store = createStore({
  name: 'counter',

  getInitialState() {
    return 0;
  },

  onStart({increment, decrement}) {
    // called when the first subscriber subscribers
  },

  onStop({increment, decrement}) {
    // called when the last subscriber unsubscribes
  },

  actions: {
    increment(currentState, n = 1) {
      return currentState + n;
    },

    decrement(currentState, n = 1) {
      return currentState - n;
    }
  }
});

store.observable.subscribe(v => console.log(v));

store.actions.increment(3);
// logs: 3
store.actions.decrement(2);
// logs 2

Creating a tracking store

import {createTrackingStore} from '@bripkens/rxstore';

const store = createTrackingStore({
  name: 'current time',
  observable: Rx.Observable.interval(1000)
});

store.observable.subscribe(v => console.log(v));

Handling uncaught errors

import {setUncaughtErrorHandler} from '@bripkens/rxstore';

setUncaughtErrorHandler((location, error, state, actioName, args) => {
  // do something with this info
});

FAQs

Package last updated on 31 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc