Last active
March 29, 2017 11:06
-
-
Save Maarten88/f4baf41db31c47ee155ed46292191a51 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Defined separately from the grain, this reducer can be taken out and shared with | |
// a Xamarin / XAML app using Redux.NET as the clientside store | |
public static CounterState Reducer(CounterState state, IAction action) | |
{ | |
switch (action) | |
{ | |
case IncrementCounterAction a: | |
return new CounterState(state) { Count = (state?.Count ?? 0) + 1 }; | |
case DecrementCounterAction a: | |
return new CounterState(state) { Count = (state?.Count ?? 0) - 1 }; | |
case StartCounterAction a: | |
return new CounterState(state) { Started = true }; | |
case StopCounterAction a: | |
return new CounterState(state) { Started = false }; | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment