Skip to content

Commit

Permalink
all OneWay bindings obtained from default
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyson Williams committed Dec 6, 2020
1 parent a1f30fa commit 5b84de4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Elmish.WPF/Binding.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Elmish.WPF
namespace Elmish.WPF

open System.Collections.Generic
open System.Collections.ObjectModel
Expand Down Expand Up @@ -903,16 +903,21 @@ module internal Helpers =
[<AbstractClass; Sealed>]
type Binding private () =


static member private defaultOneWayBinding () : string -> Binding<'model, 'msg> =
{ Get = id }
|> OneWayData.box
|> OneWayData
|> createBinding


/// <summary>Creates a one-way binding.</summary>
/// <param name="get">Gets the value from the model.</param>
static member oneWay
(get: 'model -> 'a)
: string -> Binding<'model, 'msg> =
{ Get = get }
|> OneWayData.box
|> OneWayData
|> createBinding
Binding.defaultOneWayBinding ()
>> Binding.mapModel get


/// <summary>
Expand All @@ -925,10 +930,8 @@ type Binding private () =
static member oneWayOpt
(get: 'model -> 'a option)
: string -> Binding<'model, 'msg> =
{ Get = get }
|> OneWayData.boxOpt
|> OneWayData
|> createBinding
Binding.defaultOneWayBinding ()
>> Binding.mapModel (get >> Option.toObj)


/// <summary>
Expand All @@ -941,10 +944,8 @@ type Binding private () =
static member oneWayOpt
(get: 'model -> 'a voption)
: string -> Binding<'model, 'msg> =
{ Get = get }
|> OneWayData.boxVOpt
|> OneWayData
|> createBinding
Binding.defaultOneWayBinding ()
>> Binding.mapModel (get >> ValueOption.toObj)


/// <summary>
Expand Down

0 comments on commit 5b84de4

Please sign in to comment.