Skip to content

Commit

Permalink
Add public box/unbox for Binding<> types
Browse files Browse the repository at this point in the history
  • Loading branch information
marner2 committed Dec 9, 2022
1 parent 3cc05e9 commit 02929c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Elmish.WPF/Binding.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module Binding =
{ Name = binding.Name
Data = binding.Data |> f }

/// Boxes the output parameter
let boxT (binding: Binding<'b, 'msg, 't>) = BindingData.boxT |> mapData <| binding

/// Unboxes the output parameter
let unboxT (binding: Binding<'b, 'msg>): Binding<'b, 'msg, 't> = BindingData.unboxT |> mapData <| binding

/// Maps the model of a binding via a contravariant mapping.
let mapModel (f: 'a -> 'b) (binding: Binding<'b, 'msg, 't>) = f |> mapModel |> mapData <| binding

Expand Down
1 change: 1 addition & 0 deletions src/Elmish.WPF/BindingData.fs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ and BindingData<'model, 'msg, 't> =

module BindingData =

let unboxT b = MapT.recursiveCase unbox box b
let mapModel f =
let binaryHelper binary x m = binary x (f m)
let baseCase = function
Expand Down

0 comments on commit 02929c4

Please sign in to comment.