Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Projection class is redesigned here. It now only suports read & reduce based on existing events, without possibility to subscribe for events. New & redesigned: * replace `from_all_streams` & `from_stream` with passing read scopes to `call` method, it allows to fully use all read specification features to define what events should be handled * instead of providing several streams (and starting points) to be processed `call` expects several read scopes * `when` method replaced with `on` method, with usage consistent with `on` handlers (as in `AggregateRoot`), the `on` methods require block to process state & event and it must return new projection state * allows to use simple values as initial state, no need to use hash to pass values, `nil` is the initial default state now * initial state is passed to projection using costructor Typical usage: ```ruby account_balance = RailsEventStore::Projection .new(0.0) .on(MoneyDeposited) { |state, event| state += event.data[:amount] } .on(MoneyWithdrawn) { |state, event| state -= event.data[:amount] } .call(client.read) ```
- Loading branch information