Jason Warner
1 min readJun 18, 2021

--

This is a good callout. My article glosses over what I was thinking. It is difficult to create an example simple enough to demonstrate a principle and not be a bit contrived.

What I was thinking about was a property that is added to the component store that will be set to true when a save is completed. This would give a way to notify consumers that a save was completed. We could even add a status object to know if it was a success or an error. The down-side to this approach is that in the component store, the last value is stored and emitted on subscribe much like a BehaviorSubject. Now consumers have to ignore the first emit or the code to save has to "reset" this value before saving. This is what I mean by a potentially error-prone implementation. Programmers have to know a bit about the implementation to properly work with our state object.

What I really want is to simulate an action from Ngrx. A simple fire-and-forget observable that can trigger other actions like turning off a spinner or popping up a toast. I admit that the explanation was simplistic and that the example is a little contrived. 😊 I do think that the principle is sound and is useful in certain situations. In a lot of situations, adding a property to the component store is the easiest to maintain and understand.

Thank you for the feedback. It gave me pause and had me think about what I wrote.

--

--

Jason Warner
Jason Warner

Written by Jason Warner

I enjoy everything related to code and being a dev. However, my only skills are showing up and being lucky and I'm not sure if luck is a talent.

No responses yet