-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
45 lines (35 loc) · 1.26 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
<html>
<head>
<script src="./dist/model-o.min.js"></script>
</head>
<body>
<h1>Check the console, dude!</h1>
<a href="https://github.com/positlabs/model-o/blob/master/index.html">VIEW SOURCE</a>
<a href="https://github.com/positlabs/model-o/"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
<script>
var model = new Model_O({
str: 'hello',
obj: {
a: 'a' // NOTE: unwatchable
},
subModel: new Model_O({
a: 'a' // watchable
}),
bool: true,
num: 123.4567,
arr: [1, 2, 3, 4, 5]
})
console.log(model)
var onChange = function(newval, oldval, key){
console.log(key, 'newval: ' + newval + ', oldval: ' + oldval)
}
model.on('str', onChange)
model.str = 'asdf'
model.str += 'asdf'
model.subModel.on('a', onChange)
model.subModel.a = 'A'
model.on('arr', onChange)
model.arr = model.arr.concat('extra')
</script>
</body>
</html>