Created
August 2, 2017 19:21
-
-
Save olexale/2cf6b592fd6af16430d3c0de2ed3d9f0 to your computer and use it in GitHub Desktop.
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
class CounterReducer | |
{ | |
public CounterState Reduce(CounterState state, object action) | |
{ | |
switch (action) | |
{ | |
case IncrementAction i: | |
return ProcessIncrement(state); | |
case DecrementAction d: | |
return ProcessDecrement(state); | |
default: | |
throw new ArgumentException("action is not supported"); | |
} | |
} | |
private CounterState ProcessIncrement(CounterState state) | |
{ | |
return new CounterState(state.Count + 1); | |
} | |
private CounterState ProcessDecrement(CounterState state) | |
{ | |
return new CounterState(state.Count - 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment