New Immutable Pipe "freezeUntil" for Observables #6673
gogogoober
started this conversation in
Ideas / Feature request
Replies: 1 comment
-
Use something like Object.freeze(), deepfreeze and readonly from typescript? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently Im able to get some form of immutability in observables but not at runtime. In angular, if I use ngModel directly on an observable Im able to modify its value.
Using the code below I'm able to ensure only the methods in my service can modify the Behavior subject and at compile time my observable is locked down and cant be modified externally. This however doesn't apply to complete that use | async then use an ngModel for a template form.
private readonly _orders = new BehaviorSubject<Order[]>([]);
readonly orders$= this._orders.asObservable();
Our team is looking to implement Redux just for its immutability. it will drag with it a ton of boiler plate and complexity to accomplish ONE goal. Immutability.
private ordersEditable$ = new BehaviorSubject(false);
public orders$ = new BehaviorSubject([]).pipe(freezeUntil(ordersEditable$))
Beta Was this translation helpful? Give feedback.
All reactions