-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscalars.html
More file actions
44 lines (37 loc) · 1.1 KB
/
Copy pathscalars.html
File metadata and controls
44 lines (37 loc) · 1.1 KB
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
<!DOCTYPE html>
<html>
<head>
<link href="prism.css" rel="stylesheet" />
<link href="index.css" rel="stylesheet" />
<script src="../../dist/supermodels.js"></script>
<script src="examples.js"></script>
<script class="code">
// Schemas can be as simple as this
var modelSchema = 4;
// If a primitive passed to supermodels,
// a wrapper is returned, with the
// default value a the primitive value
var Model = supermodels(modelSchema);
var model = new Model();
console.log(model.getValue()); //=> 4
model.setValue('3');
console.log(model.getValue()); //=> '3'
// Here;s a schema that describes a
// Number with an initial value of 42
var modelSchema1 = {
__type: Number,
__value: 42
};
var Model1 = supermodels(modelSchema1);
var model1 = new Model1();
console.log(model.getValue()); //=> 4
model.setValue('3');
console.log(model.getValue()); //=> 3 Cast to a number
</script>
</head>
<body>
<pre class="language-javascript"><code class="language-javascript"></code></pre>
<script src="index.js"></script>
<script src="prism.js"></script>
</body>
</html>