Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

rxjs-observable-store

1.0.1 • Public • Published

rxjs-observable-store

npm npm MIT licensed

A state management solution implemented using RxJS to mimic Redux architecture.

Read my blog post State management in Angular with observable store services to learn more about how to use the rxjs-observable-store package to manage state in front-end applications.

Installation

npm install rxjs-observable-store --save

Usage

import {Store} from 'rxjs-observable-store';
 
class TestState {
    testProperty: string = 'initial value';
}
 
class TestStore extends Store<TestState> {
    constructor () {
        super(new TestState());
    }
 
    updateTestProperty (): void {
        this.setState({
            ...this.state,
            testProperty: 'updated value',
        });
    }
}
 
class TestComponent {
    store: TestStore;
 
    constructor () {
        this.store = new TestStore();
 
        this.store.state$.subscribe(state => {
            console.log(state);
        });
 
        setTimeout(() => {
            this.store.updateTestProperty();
        }, 3000);
    }
}

install

npm i rxjs-observable-store

Downloadsweekly downloads

46

version

1.0.1

license

MIT

homepage

jurebajt.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability