Skip to content

Commit

Permalink
correct bind typo
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardtoconnor committed Jan 24, 2019
1 parent 2fa5eed commit a435f0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ __!! Skylight is not even an alpha, just a jumping off point and not intended fo

The model is a hybrid of both MVVM and Elmish MVU, where a model is mapped into a view like MVU, but it is only done once on the initial render, with all subsequent updates propegating through targeted bindings. The targeted updates of model properties requires the model to be mutable, and the targets are defined using FSharp Quotations eg `<@ model.Property @>`.

In order to an update properties, and ensure they pass through the binding infrastrucutre, properties are never set directly like `model.Property <- value` as this will only update the model, not propegate it through the UI. All binding/mapping functions will allow you to return a value, and this will set the target property given by a FSharp Quotation `(<@ model.Prop @>,fun () -> "myValue")`
to allow multiple updates, there are overloads for these funtions eg `<@ model.P1 @>,<@ model.P2 @>,fun () -> "P1Value" , "P2Value")`.
In order to an update properties, and ensure they pass through the binding infrastrucutre, properties are never set directly like `model.Property <- value` as this will only update the model, not propegate it through the UI. All binding/mapping functions will allow you to return a value, and this will set the target property given by a FSharp Quotation `(<@ model.Prop @>,fun _ _ -> "myValue")` to allow multiple updates, there are overloads for these funtions eg `<@ model.P1 @>,<@ model.P2 @>,fun _ _ -> "P1Value" , "P2Value")`.

## The Model
We define our model with F# records like:
Expand All @@ -32,7 +31,7 @@ let mainView model = // a render function
// simple bind
label { content <@ model.Name @> }
// bind with map (int -> string)
label { content (<@ model.Age @>,fun ()-> string model.Age) }
label { content (<@ model.Age @>,fun i -> string i) }
// another simple bind
label { content <@ model.Address @> }
]
Expand Down
2 changes: 1 addition & 1 deletion Skylight/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ let mainView (model:MyModel) =
}
)
}


[<EntryPoint;STAThread>]
let main argv =
Expand Down

0 comments on commit a435f0f

Please sign in to comment.