Created
March 8, 2014 19:58
-
-
Save yreynhout/9438016 to your computer and use it in GitHub Desktop.
Playground for flavors of declarative projections in C# ... seeking the DSL so to speak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TState is an individual, immutable state entry in the projection state | |
// Flavor 1: | |
Projection<TState>. | |
When<TEvent>.ThenAdd<TKey, TEvent>(Func<TEvent, TKey> selector, Func<TEvent, TState> handler). | |
When<TEvent>.ThenUpdate<TKey, TEvent>(Func<TEvent, TKey> selector, Func<TState, TEvent, TState> handler). | |
When<TEvent>.ThenAddOrUpdate<TKey, TEvent>(Func<TEvent, TKey> selector, Func<TEvent, TState> addHandler, Func<TState, TEvent, TState> updateHandler) | |
When<TEvent>.ThenRemove<TKey, TEvent>(Func<TEvent, TKey> selector) | |
// TState is an individual, immutable state entry in the projection state | |
// Flavor 2: Add & Update melted into Set leaving the host to deal with Add or Update semantics | |
Projection<TState>. | |
When<TEvent>.ThenSet<TKey, TEvent>(Func<TEvent, TKey> selector, Func<TState, TEvent, TState> handler). | |
When<TEvent>.ThenRemove<TKey, TEvent>(Func<TEvent, TKey> selector) | |
// TState is the entire projection state | |
// Flavor 3: Immutable state. Courtesy of @gregyoung | |
Projection<TState>. | |
When<TEvent>(Func<TState, TEvent, TState> handler) | |
// TState is the entire projection state | |
// Flavor 4: Mutable state. Courtesy of @peterhagues | |
Projection<TState>. | |
When<TEvent>(Action<TState, TEvent> handler) | |
// Look ma, no state. Courtesy of @gregyoung | |
// Flavor 5: | |
Projection. | |
When<TEvent>(Action<TEvent> handler) | |
// Projac style. | |
// Flavor 6: | |
Projection. | |
When<TEvent>(Func<TEvent, IEnumerable<TSqlNonQueryStatement>> handler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment