Derived Reactive Observable State with Slice | Task

Ole Ersoy
Feb - 11  -  2 min


Our application calculates an Observable<Result>.

We store this result in our Firefly Semantics Slice Object Store ( OStore).

We want to know when the result is ready, such that we can enable the save button.


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);

Observe this value:

const isResultReady$: Observable<boolean> = OS.S.RESULT.obs.pipe(
    map(r => {  return !!r;})


When we update the value of RESULT to a non null value, true is logged. When RESULT is set to null false is logged:

Error Modeling and Broadcast

We could also create an ERROR Observable in our store. Whenever we broadcast error data, we could indicate that the error has occurred using the same technique like this:

const hasErrorOccurred$: Observable<boolean> = OS.S.ERROR.obs.pipe(
    map(r => {  return !!r;})