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 Sep 9, 2022
1 parent c7f4e8e commit 8393249
Show file tree
Hide file tree
Showing 3 changed files with 4 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 @@ -127,7 +127,7 @@ module Helpers =
AutoRequery = autoRequery }
|> CmdData
|> BaseBindingData
|> createBinding) name
|> Binding.createBinding) name


let internal subModel
Expand Down
5 changes: 3 additions & 2 deletions src/Elmish.WPF/Binding.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ open Elmish


module Binding =
let internal createBinding data name = { Data = data |> BindingData.boxT; Name = name }
open BindingData

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 |> BindingData.boxT }

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 8393249

Please sign in to comment.