Header menu logo Sutil

StoreOperators Module

Operators for store functions

Functions and values

Function or value Description

v -~> s

Full Usage: v -~> s

Parameters:

Alias for Store.set, replaces the current value of the store

v : 'a
s : IStore<'a>
Example

     2 -~> intStore
     let value = Store.get intStore
     value = 1 // false
val value: int

s .> f

Full Usage: s .> f

Parameters:
Returns: IObservable<'b>

Alias for Store.map, returns an observable that will resolve to the result of said callback

s : IObservable<'a>
f : 'a -> 'b
Returns: IObservable<'b>
Example

     let subscription: IObservable<string> =
         intStore .> (fun value -> $"{value}")

     (* after you are done with the subscription *)

     subscription.Dispose()
val subscription: obj
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String
val value: obj

s .>> f

Full Usage: s .>> f

Parameters:
Returns: IObservable<'b>

Alias for Store.mapDistinct

s : IObservable<'a>
f : 'a -> 'b
Returns: IObservable<'b>

s <~ v

Full Usage: s <~ v

Parameters:

Alias for Store.set, replaces the current value of the store

s : IStore<'a>
v : 'a
Example

     intStore <~ 2
     let value = Store.get intStore
     value = 1 // false
val value: int

s <~- v

Full Usage: s <~- v

Parameters:

Alias for Store.set, replaces the current value of the store

s : IStore<'a>
v : 'a
Example

     intStore <~- 2
     let value = Store.get intStore
     value = 1 // false
val value: int

store <~= map

Full Usage: store <~= map

Parameters:
    store : Store<'a>
    map : 'a -> 'a

Alias for Store.modify. Modify the store by mapping its current value with a callback

store : Store<'a>
map : 'a -> 'a
Example

     let store: IStore<int> = Store.make 2

     let squareMe() =
         store <~= (fun model -> model * model)

     Html.div [
         bindFragment store <| fun model -> text $"The value is {model}"
         Html.button [
             onClick (fun _ -> squareMe()) []
             text "Square me"
         ]
     ]
val store: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
val squareMe: unit -> obj
val model: int

map =~> store

Full Usage: map =~> store

Parameters:
    map : 'a -> 'a
    store : Store<'a>

Alias for Store.modify Modify the store by mapping its current value with a callback

map : 'a -> 'a
store : Store<'a>
Example

     let store: IStore<int> = Store.make 2

     let squareMe() =
         (fun model -> model * model) =~> store

     Html.div [
         bindFragment store <| fun model -> text $"The value is {model}"
         Html.button [
             onClick (fun _ -> squareMe()) []
             text "Square me"
         ]
     ]
val store: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
val squareMe: unit -> obj
val model: int

s |-> f

Full Usage: s |-> f

Parameters:
Returns: 'b

Alias for Store.getMap, takes a store and applies a mapping function then returns the value from the evaluated function

This might be called foldMap

s : IStore<'a>
f : 'a -> 'b
Returns: 'b
Example

     let store: IStore<{| name: string; budget: decimal |}> =
     Store.make {| name = "Frank"; budget = 547863.26M |}

     let formattedBudget: string =
         store |-> (fun model -> sprintf $"$ %0.00M{model.budget}")
     printf %"Budget available: {formattedBudget}
val store: 'a
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String
Multiple items
val decimal: value: 'T -> decimal (requires member op_Explicit)

--------------------
type decimal = System.Decimal

--------------------
type decimal<'Measure> = decimal
val formattedBudget: string
val model: obj
val sprintf: format: Printf.StringFormat<'T> -> 'T
val printf: format: Printf.TextWriterFormat<'T> -> 'T

Type something to start searching.