TwoWayProjection

interface TwoWayProjection<M, in T, C>

A TwoWayProjection applies a sequence of events of type T to a model of type M. This is a more advanced projection than OneWayProjection, because it allows sites to define a custom change type C which will contain meta-data to undo the application of an event. Therefore, it applies operations in multiple directions.

This is particularly useful if the underlying model can not be efficiently implemented as a persistent data structure.

Parameters

M

the type of the model.

T

the type of the events.

C

the type of the changes.

Functions

Link copied to clipboard
abstract fun backward(    model: M,     id: EventIdentifier,     event: T,     change: C): M

Reverses a change issued during forward traversal.

Link copied to clipboard
abstract fun ChangeScope<C>.forward(    model: M,     id: EventIdentifier,     event: T): M

Applies the event to the given model, and returns a new immutable model. Additionally, changes should be issued using the ChangeScope.