-
Notifications
You must be signed in to change notification settings - Fork 57
/
index.html
60 lines (58 loc) · 3.03 KB
/
index.html
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
<html>
<head>
<script src="//netflix.github.io/falcor/build/falcor.browser.js">
</script>
<script>
//create model:
var model = new falcor.Model({
source: new falcor.HttpDataSource('/model.json')
});
//logging:
var log = console.log.bind(console);
var jlog = function(x) { console.log(JSON.stringify(x, null, 3)); };
var jerror = function(x) { console.error(JSON.stringify(x, null, 3)); };
//examples:
// model.get('genrelist[0..5].titles[0..5].name').then(function (data) {
// console.log(data);
// });
// model.get('genrelist[0].name').then(jlog, jerror)
// model.get('titlesById[-1]["userRating", "name"]').then(jlog, jerror)
// model.setValue('titlesById[9].userRating', 9).then(jlog, jerror)
// model.setValue('genrelist[0].titles[2].userRating', 3).then(jlog, jerror)
// model.get('genrelist[0].titles[0..2]["userRating", "name"]').then(function(x) {
// jlog(x)
// model.setValue('genrelist[0].titles[1].userRating', 8).then(function(y) {
// jlog(y)
// model.get('genrelist[0].titles[0..2]["userRating", "name"]').then(jlog, jerror)
// }, jerror)
// }, jerror)
// model.get('titlesById[26,5,4].userRating').then(jlog, jerror)
// model.get('titlesById[3,4,5]["name", "year", "description"]').then(jlog, jerror)
// model.get('genrelist[10].titles.length').then(jlog, jerror)
// model.get('genrelist[10].titles[0..10]["name", "year", "boxshot"]').then(jlog, jerror)
// model.get('genrelist[0].titles[0]').subscribe(jlog, jerror)
// model.get('genrelist.length').then(jlog, jerror)
// model.get('genrelist[0].titles.length').then(function(z) {
// jlog(z)
// model.call('genrelist[0].titles.push', [{$type: "ref", value: ['titlesById', 1]}], ["name", "rating"], ["length"]).then(function(x) {
// jlog(x);
// var index = x.json.genrelist[0].titles.length - 1
// log(index)
// model.call('genrelist[0].titles.remove', [index]).then(function(y) {
// jlog(y)
// model.get('genrelist[0].titles[' + (index + 1) + ']["name", "year"]').then(jlog, jerror)
// }, jerror);
// }, jerror);
// }, jerror)
// model.setValue('titlesById[0].userRating', 4).then(jlog, jerror) // this is expected to fail
// model.get('titlesById[1]["userRating", "rating"]').then(jlog, jerror)
// model.get('titlesById[0, 1, 2, 3]["year", "rating", "userRating"]').then(jlog, jerror)
// model.get('titlesById[1234].userRating').then(jlog, jerror)
// model.get('genrelist.myList.name').then(jlog, jerror)
// model.get('genrelist.myList.titles[0..1]["name", "boxshot", "rating", "userRating"').then(jlog, jerror)
// model.get('genrelist.myList.titles.length').then(jlog, jerror)
</script>
</head>
<body>
</body>
</html>