Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple cleanup to improve interop (data first)
Browse files Browse the repository at this point in the history
marner2 committed Aug 15, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d7e7b18 commit 6dd7b74
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
@@ -127,7 +127,7 @@ module Helpers =
AutoRequery = autoRequery }
|> CmdData
|> BaseBindingData
|> createBinding) name
|> Binding.createBinding) name


let internal subModel
5 changes: 3 additions & 2 deletions src/Elmish.WPF/Binding.fs
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions src/Elmish.WPF/DynamicViewModel.fs
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 6dd7b74

Please sign in to comment.