/simple-persist-rxjs

RxJS decorator for SimplePersist

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

SimplePersist RxJS

SimplePersist decorator to handle RxJS Subjects & BehaviorSubjects

Table of Contents

Installation

npm install @simple-persist/rxjs

Quick start

Add @PersistSubject() decorator to a Subject or BehaviorSubject class property:

import { PersistSubject } from '@simple-persist/rxjs';
import { BehaviorSubject, Subject } from 'rxjs';

class Foo {
  @PersistSubject() public bar?: Subject;
  // or
  @PersistSubject() public baz?: BehaviorSubject;
}

Note: All configuration options of @Persist() from @simple-persist/core are available for @PersistSubject() as well. Use the same syntax to define custom keygens, middlewares or storage for your decorator!

Read more

For more information (caveats, advanced use, other extensions) see @simple-persist/core.

Check out my article about the reasoning behind this package: Do we need state management in Angular?

Collaboration

Feel free to suggest features, open issues, or contribute! Also let me know about your extensions, so I can link them in this document.