Filtering Firefly Semantics Slice Object Store Observables by Property Value


We want the ability to observe reactive Firefly Semantics Slice Object Store Events filtered by property name and value.


Use the onFilteredEvent<E> function provided as part of the Firefly Semantics Slice utility library. It is defined like this.

export function onFilteredEvent<E>(
value: any,
propertyName: string
obs: Observable<E>): Observable<E> {
return obs.pipe(
filter((e) => !!(e && e[propertyName] === value)));

The RxJS filter expression checks that the event (e) is defined and that the value argument matches the value identified by the propertyName argument. The obs argument is the Observable argument provided by the Firefly Semantics Slice Object Store.


In this demo we created a NamedEvent type that has a name property that we will be targeting.

export type NamedEvent = { name: string };const namedEvent: NamedEvent = { name: 'hilde' };

We also created the instance namedEvent setting name to hilde . We use it to initialize our object store.

const START: OStoreStart = {
event: { value: namedEvent },
interface ISTART extends KeyObsValueReset {
event: ObsValueReset;
let OS: OStore<ISTART> = new OStore(START);

We can now filter for events where the property name is set to hilde like this:

const hildeEvents$: Observable<NamedEvent> = onFilteredEvent<NamedEvent>(



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
Ole Ersoy

Ole Ersoy

Founder of Firefly Semantics Corporation