1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>JSDoc: Source: jsframework/core/internal/state.js</title>
|
6 |
|
7 | <script src="scripts/prettify/prettify.js"> </script>
|
8 | <script src="scripts/prettify/lang-css.js"> </script>
|
9 | |
10 |
|
11 |
|
12 | <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13 | <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14 | </head>
|
15 |
|
16 | <body>
|
17 |
|
18 | <div id="main">
|
19 |
|
20 | <h1 class="page-title">Source: jsframework/core/internal/state.js</h1>
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | <section>
|
28 | <article>
|
29 | <pre class="prettyprint source linenums"><code>/**
|
30 | * Created by zhangmike on 16/10/18.
|
31 | */
|
32 |
|
33 | export default function initState(GMP) {
|
34 | /**
|
35 | * Setup the scope of an instance, which contains:
|
36 | * - observed data
|
37 | */
|
38 | GMP._assignPros({
|
39 | _initState() {
|
40 | this._initData();
|
41 | },
|
42 | _initData() {
|
43 | this._data = this.$options.data || {};
|
44 | var keys = Object.keys(this._data);
|
45 | var that = this;
|
46 | for (var i = 0, l = keys.length; i < l; i++) {
|
47 | var key = keys[i],
|
48 | val = this._data[keys[i]];
|
49 | var property = Object.getOwnPropertyDescriptor(this._data, key);
|
50 | if (property && property.configurable === false) {
|
51 | continue;
|
52 | }
|
53 |
|
54 | (function(k, v) {
|
55 | Object.defineProperty(that._data, k, {
|
56 | enumerable: true,
|
57 | configurable: true,
|
58 | get: function reactiveGetter () {
|
59 | return v;
|
60 | },
|
61 | set: function reactiveSetter (newVal) {
|
62 | var value = v;
|
63 | if (newVal === value) {
|
64 | return;
|
65 | }
|
66 | v = newVal;
|
67 | }
|
68 | });
|
69 | })(key, val);
|
70 | }
|
71 | }
|
72 | });
|
73 | }
|
74 | </code></pre>
|
75 | </article>
|
76 | </section>
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | </div>
|
82 |
|
83 | <nav>
|
84 | <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="global.html#GMP">GMP</a></li><li><a href="module.html#.exports">exports</a></li></ul><h3>Global</h3><ul><li><a href="global.html#isType">isType</a></li><li><a href="global.html#uid">uid</a></li></ul>
|
85 | </nav>
|
86 |
|
87 | <br class="clear">
|
88 |
|
89 | <footer>
|
90 | Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Mon Oct 24 2016 18:10:18 GMT+0800 (CST)
|
91 | </footer>
|
92 |
|
93 | <script> prettyPrint(); </script>
|
94 | <script src="scripts/linenumber.js"> </script>
|
95 | </body>
|
96 | </html>
|