Last active
December 9, 2023 14:33
-
-
Save adospace/cbede42c410c642dbdbcafe9ece5e90b to your computer and use it in GitHub Desktop.
MauiReactor + Fluxor POC
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 MainPage : Component | |
{ | |
protected override void OnMounted() | |
{ | |
var store = Services.GetRequiredService<IStore>(); | |
store.InitializeAsync().Wait(); | |
var state = Services.GetRequiredService<IState<CounterState>>(); | |
state.StateChanged += State_StateChanged; | |
base.OnMounted(); | |
} | |
private void State_StateChanged(object sender, EventArgs e) | |
{ | |
Invalidate(); | |
} | |
public override VisualNode Render() | |
{ | |
var state = Services.GetRequiredService<IState<CounterState>>(); | |
return new ContentPage | |
{ | |
new VStack | |
{ | |
new Button(state.Value.ClickCount == 0 ? "Click me" : $"Clicked {state.Value.ClickCount} times!") | |
.OnClicked(OnButtonClicked) | |
.HCenter() | |
} | |
.VCenter() | |
}; | |
} | |
private void OnButtonClicked() | |
{ | |
var dispatcher = Services.GetRequiredService<IDispatcher>(); | |
dispatcher.Dispatch(new IncrementCounterAction()); | |
} | |
} |
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 static class MauiProgram | |
{ | |
public static MauiApp CreateMauiApp() | |
{ | |
var builder = MauiApp.CreateBuilder(); | |
builder | |
.UseMauiReactorApp<MainPage>(app => | |
{ | |
app.AddResource("Resources/Styles/Colors.xaml"); | |
app.AddResource("Resources/Styles/Styles.xaml"); | |
app.SetWindowsSpecificAssectDirectory("Assets"); | |
}) | |
.ConfigureSyncfusionCore() | |
#if DEBUG | |
.EnableMauiReactorHotReload() | |
#endif | |
.ConfigureFonts(fonts => | |
{ | |
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | |
fonts.AddFont("OpenSans-SemiBold.ttf", "OpenSansSemiBold"); | |
}); | |
return builder.Build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment