Scenario
We have a Firefly Semantics Slice OStore
initialized with this OStoreStart
object:
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
This is a pure typescript demo: