Skip to content

Commit

Permalink
Simple cleanup to improve interop (data first)
Browse files Browse the repository at this point in the history
  • Loading branch information
marner2 committed Nov 1, 2022
1 parent 6a622fb commit f534739
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Elmish.WPF.Tests/DynamicViewModelTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module Helpers =
AutoRequery = autoRequery }
|> CmdData
|> BaseBindingData
|> createBinding) name
|> Binding.createBinding) name


let internal subModel
Expand Down
8 changes: 6 additions & 2 deletions src/Elmish.WPF/Binding.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ open Elmish
module Binding =
open BindingData

let internal createBinding data name =
{ Data = data
Name = name }

let internal mapData f binding =
{ Name = binding.Name
Data = binding.Data |> f }
{ Data = binding.Data |> f
Name = binding.Name }

/// Maps the model of a binding via a contravariant mapping.
let mapModel (f: 'a -> 'b) (binding: Binding<'b, 'msg>) = f |> mapModel |> mapData <| binding
Expand Down
4 changes: 0 additions & 4 deletions src/Elmish.WPF/DynamicViewModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ type Binding<'model, 'msg> =
[<AutoOpen>]
module internal Helpers =

let createBinding data name =
{ Name = name
Data = data }

type SubModelSelectedItemLast with
member this.CompareBindings() : Binding<'model, 'msg> -> Binding<'model, 'msg> -> int =
fun a b -> this.Recursive(a.Data) - this.Recursive(b.Data)
Expand Down

0 comments on commit f534739

Please sign in to comment.