From f53473992a42c6138117648cee9e86603d1da2ca Mon Sep 17 00:00:00 2001 From: Joshua Marner Date: Thu, 7 Jul 2022 13:49:54 -0500 Subject: [PATCH] Simple cleanup to improve interop (data first) --- src/Elmish.WPF.Tests/DynamicViewModelTests.fs | 2 +- src/Elmish.WPF/Binding.fs | 8 ++++++-- src/Elmish.WPF/DynamicViewModel.fs | 4 ---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Elmish.WPF.Tests/DynamicViewModelTests.fs b/src/Elmish.WPF.Tests/DynamicViewModelTests.fs index 7f5e7b19..ab34f453 100644 --- a/src/Elmish.WPF.Tests/DynamicViewModelTests.fs +++ b/src/Elmish.WPF.Tests/DynamicViewModelTests.fs @@ -129,7 +129,7 @@ module Helpers = AutoRequery = autoRequery } |> CmdData |> BaseBindingData - |> createBinding) name + |> Binding.createBinding) name let internal subModel diff --git a/src/Elmish.WPF/Binding.fs b/src/Elmish.WPF/Binding.fs index 7cbf2905..28648cf2 100644 --- a/src/Elmish.WPF/Binding.fs +++ b/src/Elmish.WPF/Binding.fs @@ -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 diff --git a/src/Elmish.WPF/DynamicViewModel.fs b/src/Elmish.WPF/DynamicViewModel.fs index 31a2493e..3df3672e 100644 --- a/src/Elmish.WPF/DynamicViewModel.fs +++ b/src/Elmish.WPF/DynamicViewModel.fs @@ -18,10 +18,6 @@ type Binding<'model, 'msg> = [] 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)