Closed sandeep-eroad closed 2 years ago
Can we add the following code as a F# example ?
open System.Reflection open Fluxor open Microsoft.Extensions.DependencyInjection [<FeatureState>] [<CLIMutable>] type CounterState = { ClickCount: int } type CounterAction = | Increment | Decrement | IncrementBy of int | DecrementBy of int module Reducer = [<ReducerMethod>] let incrementCounter (state: CounterState, action: CounterAction) = match action with | Increment -> { ClickCount = state.ClickCount + 1 } | Decrement -> { ClickCount = state.ClickCount - 1 } | IncrementBy x -> { ClickCount = state.ClickCount + x } | DecrementBy x -> { ClickCount = state.ClickCount - x } type App(store: IStore, counterState: IState<CounterState>, dispatcher: IDispatcher) = do counterState.StateChanged.Add(fun x -> printfn $"-----> CounterState: {counterState.Value}") member this.Run ()= printfn "Initializing store..." store.InitializeAsync().Wait() dispatcher.Dispatch(Increment) dispatcher.Dispatch(Decrement) dispatcher.Dispatch(IncrementBy 5) dispatcher.Dispatch(DecrementBy 5) () let services = ServiceCollection() services.AddScoped<App>() |> ignore services.AddFluxor(fun x -> x.ScanAssemblies(Assembly.GetExecutingAssembly()) |> ignore) |> ignore let serviceProvider = services.BuildServiceProvider() let app = serviceProvider.GetRequiredService<App>() app.Run() printfn "Hello F#luxor"
I don't know F#, so wouldn't feel comfortable supporting it, and providing demos implies support. Sorry :(
Fair enough.
Can we add the following code as a F# example ?