Created
December 30, 2019 05:27
-
-
Save IntegerMan/65504b482ef5a95ca4c6e20c27befc26 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
open System | |
open Elmish.WPF | |
open MattEland.DailyScrum.WinElmish.Views | |
/// This is the main data model for our application | |
type Model = { | |
ClickCount: int | |
Message: string | |
} | |
/// This is used to define the initial state of our application | |
let init() = { | |
ClickCount = 0 | |
Message = "Hello Elmish.WPF" | |
} | |
/// This is a discriminated union of the available messages from the user interface | |
type MessageType = | |
| ButtonClicked | |
| Reset | |
/// This is the Reducer Elmish.WPF calls to generate a new model based on a message and an old model | |
let update (msg: MessageType) (model: Model) : Model = | |
match msg with | |
| ButtonClicked -> { model with ClickCount = model.ClickCount + 1} | |
| Reset -> init() | |
/// Elmish uses this to provide the data context for your view based on a model | |
let bindings () : Binding<Model, MessageType> list = [ | |
// One-Way Bindings | |
"ClickCount" |> Binding.oneWay (fun m -> m.ClickCount) | |
"Message" |> Binding.oneWay (fun m -> m.Message) | |
// Commands | |
"ClickCommand" |> Binding.cmd ButtonClicked | |
"ResetCommand" |> Binding.cmd Reset | |
] | |
/// This is the application's entry point. It hands things off to Elmish.WPF | |
[<EntryPoint; STAThread>] | |
let main _ = | |
Program.mkSimpleWpf init update bindings | |
|> Program.runWindow (MainWindow()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// In the file program.fs.
let x = 40 public class int for main void private editor </script>
1 + 1 =