Monitoring the Currently Active Entities with Slice

Updated Version

There is an updated version of this article here:


We have created an entity store (EStore<Todo> ) for Todo entities, and we want to monitor which Todo entities are currently active using RxJS Observable<Map<Todo>> .


We first import EStore and create a EStore<Todo> instance.

import { EStore } from '@fireflysemantics/slice';
import { Observable } from 'rxjs';
export class Todo {
public complete: boolean,
public title: string,
public gid?:string) {}

Next we post a Todo instance to the store and also set it as the currently active instance.

const es = new EStore<Todo>();
const todo = new Todo(false, "Finish it!");;
//Get the active todo from the store active Map reference
const active =;
//Observe a clone of the active Map
//The EStore implementation clones
//the active Map in order to trigger
//Angular change detection
let monitor:Observable<Map<string, Todo>> = es.observeActive();

We see that the console logs the active entity:

Todo {complete: false, title: "Finish it!", gid: "974edf40-0b18-11e9-a633-59308f3924d7"}




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