Skip to content

Instantly share code, notes, and snippets.

@FoggyFinder
Created December 5, 2016 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FoggyFinder/4a6ed9d2c5e892cac31bc271533b8e60 to your computer and use it in GitHub Desktop.
Save FoggyFinder/4a6ed9d2c5e892cac31bc271533b8e60 to your computer and use it in GitHub Desktop.
module Context =
open Gjallarhorn
open Gjallarhorn.Bindable
let rand = Random()
let choose n =
Array.sortBy (fun _ -> rand.Next()) [|0..10|]
let create () =
let source = Binding.createSource()
let count = 10
let rand = Random()
let model : IMutatable<int[]> = Mutable.create [| |]
let up items param =
//Do something with items
//now items is always = [| |] (initial value)
items
Binding.toView source "Model" model
Binding.createCommand "CreateCommand" source
|> Observable.subscribe
(fun _ -> choose count |> Mutable.set model)
|> source.AddDisposable
Binding.createMessageParam "Up" id source
|> Observable.subscribe (up model.Value >> Mutable.set model)
|> source.AddDisposable
source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment