Taking a Count Snapshot of a Firefly Semantics Slice Entity Store

Scenario
We have Product
instances that we are adding to a shopping cart that is backed by a Firefly Semantics Slice Entity Store (EStore
).
As the Widget
we want a snapshot of the number of instances in the cart.
Approach
The Firefly Semantics Entity Store has a countSnapshot():number
method that we can call to get the count of the number of entities in the store.
interface Product {id: string;name: string;}const P1: Product = {
id: '1',
name: 'Soap',
};
const P2: Product = {
id: '1',
name: 'Soap',
};
const cart: EStore<Product> = new EStore<Product>();cart.post(P1);
cart.post(P2);const count = cart.countSnapshot();
console.log(count);
// Logs 2