Typing Firefly Semantics Slice Object Store Observables | Task

Ole Ersoy
Apr - 12  -  1 min

Scenario

We model IS_AUTHENTICATED in our Firefly Semantics Slice Object Store (OStore).

const START: OStoreStart = {
  IS_AUTHENTICATED: { value: false }
};
interface ISTART {
  IS_AUTHENTICATED: ObsValueReset;
}
let OS: OStore<ISTART> = new OStore(START);

And we can access the corresponding Observable like this:

OS.S.IS_AUTHENTICATED.obs

But it will emit as an Observable<any>, and we want it to emit as Observable<boolean>.

Approach

Just create a proxy or alias as demonstrated in this article.

//=================================
// ALIASES
//=================================

const isAuthenticated$: Observable<boolean> = OS.S.IS_AUTHENTICATED.obs;

Now isAuthenitcated$ will emit as Observable<boolean>.

Demo