-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy path2.+Interactivity.snb
70 lines (70 loc) · 2.12 KB
/
2.+Interactivity.snb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
"metadata":{
"name":"2. Interactivity",
"user_save_timestamp":"2015-02-05T19:18:41.786Z",
"auto_save_timestamp":"2015-02-05T19:18:05.343Z"
},
"worksheets":[{
"cells":[{
"cell_type":"markdown",
"source":"## Interactive widgets\n\nHow do these widgets work exactly...?\n"
},{
"cell_type":"code",
"input":"// Reactive components allow dynamic communication to Scala and Javascript\nval ib = new InputBox(\"\")",
"language":"scala",
"collapsed":false,
"prompt_number":17,
"outputs":[]
},{
"cell_type":"code",
"input":"// after running this line, values typed in ib2 will get mirrored in ib\nib.currentValue.observer <-- Observable.timer(\n scala.util.Random.alphanumeric.map(_.toString).take(10), 5)",
"language":"scala",
"collapsed":false,
"prompt_number":13,
"outputs":[]
},{
"cell_type":"code",
"input":"val ib2 = new InputBox(\"\")",
"language":"scala",
"collapsed":false,
"prompt_number":18,
"outputs":[]
},{
"cell_type":"code",
"input":"ib.currentValue <-- ib2.currentValue",
"language":"scala",
"collapsed":false,
"prompt_number":15,
"outputs":[]
},{
"cell_type":"code",
"input":"// More advanced. You should read \"observer\" as \"sink\" and \"observable\" as \"source\"\nib.currentValue.observer <-- ib2.currentValue.observable.map(_.toUpperCase)",
"language":"scala",
"collapsed":false,
"prompt_number":19,
"outputs":[]
},{
"cell_type":"code",
"input":"val dropdown = new DropDown(Seq(\"a\", \"b\", \"c\"))",
"language":"scala",
"collapsed":false,
"prompt_number":20,
"outputs":[]
},{
"cell_type":"code",
"input":"dropdown.optionsConnection.observer <-- ib2.currentValue.observable.map(_.split(\",\").toSeq)",
"language":"scala",
"collapsed":false,
"prompt_number":21,
"outputs":[]
},{
"cell_type":"code",
"input":"",
"language":"scala",
"collapsed":true,
"outputs":[]
}]
}],
"autosaved":[],
"nbformat":3
}