State Tracking
We will walk through a complete example which shows how to setup Trrack for pure state-based provenance tracking.
We start by creating our initial state:
const state = {
counter: 0,
};Then we initialize the registry and register an state-update action which increments the counter with a value:
const registry = Registry.create();
const incrementAction = registry.register('increment', (state, val) => {
state.counter += val;
});We can use the state and registry to initialize Trrack as follows:
const trrack = initializeTrrack({
initialState: state,
registry,
});We can trigger updates to state by using incrementAction as follows:
trrack.apply('Increment by 1', incrementAction(1));Here is a sandbox which shows state based provenance trracking.