Slice OStore Observables Bound to OStore Keys

Image by Adina Voicu from Pixabay

Scenario

export const OSK:OStoreStart = {
IS_AUTHENTICATED: { value: false, key: '' }
}

After creating the store:

os: OStore = new OStore(OSK)

We want to access the Observable for IS_AUTHENTICATED using the IS_AUTHENTICATED label as a key.

Approach

import { OStoreStart, OStoreKeyValueReset, OStore } from "@fireflysemantics/slice";export const OSK:OStoreStart = {
IS_AUTHENTICATED: { value: false, key: '' }
}
export interface OSKI {
IS_AUTHENTICATED: OStoreKeyValueReset
}
export const os: OStore<OSKI> = new OStore<OSKI>(OSK)export const s: OSKI = os.S

I usually use the abbreviation OSK for Object Store Keys. The OSKI abbreviation stands for Object Store Keys interface.

os : The OStore

s: The OStoreStart instance with an Observable bound to the keys declared in the OSKI interface.

Demo

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store