Using the Trackable Monad

This is the Trackable class from my article on building a monad. Use map to change its value while keeping the queued analytics events. Use flatMap when the next function returns another Trackable, then execute the chain to emit its events to the log and return the value.

Build a chain

Trackable.of(2)

Transform the value

Add an event with flatMap

Both flatMap actions include this JSON in the event they create.

Trackable state

Wrapped value2

Queued events (0)

    No events queued yet. Try a flatMap action.

    Emitted events (0)

    No events emitted yet.