Updated Version
There’s an updated version of this article here:
Scenario
Our application calculates an Observable<Result>
. We store this result in our Firefly Semantics Slice Object Store.
We want to know when the result is ready, such that we can enable the save button.
Approach
First we will create our object store with an initial value of null
for RESULT
:
export const OSK: OStoreStart = {
RESULT: { value: null }
};export interface OSKI {
RESULT: ObsValueReset;
}const OS: OStore<OSKI> = new OStore<OSKI>(OSK);
Then we will observe this value:
const isResultReady$: Observable<boolean> = OS.S.RESULT.obs.pipe(
map(r => { return !!r;})
);
Demo
When we update the value of RESULT
to a non null
value, true
is logged. When RESULT
is set to null
false
is logged: