UNPKG

2.63 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>JSDoc: Source: internal/state.js</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
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: 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
33export default function initState(GMP) {
34 /**
35 * Setup the scope of an instance, which contains:
36 * - observed data
37 */
38 GMP.prototype._initState = function () {
39 this._initData();
40 };
41
42 GMP.prototype._initData = function () {
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 &lt; l; i++) {
47 var key = keys[i],
48 val = this._data[keys[i]];
49 var property = Object.getOwnPropertyDescriptor(this._data, key);
50 if (property &amp;&amp; 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};</code></pre>
73 </article>
74 </section>
75
76
77
78
79</div>
80
81<nav>
82 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="GMP.html">GMP</a></li></ul><h3>Global</h3><ul><li><a href="global.html#delegateEventSplitter">delegateEventSplitter</a></li><li><a href="global.html#uid">uid</a></li></ul>
83</nav>
84
85<br class="clear">
86
87<footer>
88 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Wed Oct 19 2016 10:19:24 GMT+0800 (CST)
89</footer>
90
91<script> prettyPrint(); </script>
92<script src="scripts/linenumber.js"> </script>
93</body>
94</html>