Last active
August 4, 2020 20:07
-
-
Save Clancey/1df421c93ee20832d793a96b30fec997 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
public abstract class StatefulView<TMessage,TModel> : View | |
{ | |
public StatefulView() { } | |
public StatefulView(TModel initialModel) | |
{ | |
state = initialModel; | |
} | |
readonly State<TModel> state = new State<TModel>(); | |
public void Dispatch(TMessage message) | |
{ | |
var model = Update(message, state.Value); | |
state.Value = model; | |
} | |
[Body] | |
View body() => View(state.Value); | |
public abstract TModel Update(TMessage message, TModel model); | |
public abstract View View(TModel model); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment