Monitoring the Currently Active Entities with Slice

Ole Ersoy
1 min readDec 29, 2018


Photo by Aman Bhargava on Unsplash

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"}