SimplePersist decorator to handle RxJS Subjects & BehaviorSubjects
npm install @simple-persist/rxjs
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!
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?
Feel free to suggest features, open issues, or contribute! Also let me know about your extensions, so I can link them in this document.