Skip to content

Commit 33399f1

Browse files
committed
[build] 0.7.0
1 parent a78d862 commit 33399f1

File tree

2 files changed

+32
-37
lines changed

2 files changed

+32
-37
lines changed

dist/vuex.js

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Vuex v0.6.3
2+
* Vuex v0.7.0
33
* (c) 2016 Evan You
44
* Released under the MIT License.
55
*/
@@ -9,20 +9,19 @@
99
(global.Vuex = factory());
1010
}(this, function () { 'use strict';
1111

12-
var babelHelpers = {};
13-
babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
12+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
1413
return typeof obj;
1514
} : function (obj) {
1615
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
1716
};
1817

19-
babelHelpers.classCallCheck = function (instance, Constructor) {
18+
var classCallCheck = function (instance, Constructor) {
2019
if (!(instance instanceof Constructor)) {
2120
throw new TypeError("Cannot call a class as a function");
2221
}
2322
};
2423

25-
babelHelpers.createClass = function () {
24+
var createClass = function () {
2625
function defineProperties(target, props) {
2726
for (var i = 0; i < props.length; i++) {
2827
var descriptor = props[i];
@@ -40,7 +39,7 @@
4039
};
4140
}();
4241

43-
babelHelpers.toConsumableArray = function (arr) {
42+
var toConsumableArray = function (arr) {
4443
if (Array.isArray(arr)) {
4544
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
4645

@@ -50,8 +49,6 @@
5049
}
5150
};
5251

53-
babelHelpers;
54-
5552
/**
5653
* Merge an array of objects into one.
5754
*
@@ -89,7 +86,7 @@
8986
function deepClone(obj) {
9087
if (Array.isArray(obj)) {
9188
return obj.map(deepClone);
92-
} else if (obj && (typeof obj === 'undefined' ? 'undefined' : babelHelpers.typeof(obj)) === 'object') {
89+
} else if (obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') {
9390
var cloned = {};
9491
var keys = Object.keys(obj);
9592
for (var i = 0, l = keys.length; i < l; i++) {
@@ -110,9 +107,8 @@
110107
var Watcher = void 0;
111108
function getWatcher(vm) {
112109
if (!Watcher) {
113-
var unwatch = vm.$watch('__vuex__', function (a) {
114-
return a;
115-
});
110+
var noop = function noop() {};
111+
var unwatch = vm.$watch(noop, noop);
116112
Watcher = vm._watchers[0].constructor;
117113
unwatch();
118114
}
@@ -149,20 +145,13 @@
149145
};
150146

151147
function override (Vue) {
152-
// override init and inject vuex init procedure
153-
var _init = Vue.prototype._init;
154-
Vue.prototype._init = function () {
155-
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
156-
157-
options.init = options.init ? [vuexInit].concat(options.init) : vuexInit;
158-
_init.call(this, options);
159-
};
148+
Vue.mixin({ init: init });
160149

161150
/**
162151
* Vuex init hook, injected into each instances init hooks list.
163152
*/
164153

165-
function vuexInit() {
154+
function init() {
166155
var options = this.$options;
167156
var store = options.store;
168157
var vuex = options.vuex;
@@ -179,8 +168,8 @@
179168
console.warn('[vuex] store not injected. make sure to ' + 'provide the store option in your root component.');
180169
}
181170
var state = vuex.state;
182-
var getters = vuex.getters;
183171
var actions = vuex.actions;
172+
var getters = vuex.getters;
184173
// handle deprecated state option
185174

186175
if (state && !getters) {
@@ -254,8 +243,8 @@
254243
var vm = store._vm;
255244
var Watcher = getWatcher(vm);
256245
var Dep = getDep(vm);
257-
var watcher = new Watcher(vm, function (state) {
258-
return getter(state);
246+
var watcher = new Watcher(vm, function (vm) {
247+
return getter(vm.state);
259248
}, null, { lazy: true });
260249
var computedGetter = function computedGetter() {
261250
if (watcher.dirty) {
@@ -333,7 +322,7 @@
333322
var middlewares = _ref$middlewares === undefined ? [] : _ref$middlewares;
334323
var _ref$strict = _ref.strict;
335324
var strict = _ref$strict === undefined ? false : _ref$strict;
336-
babelHelpers.classCallCheck(this, Store);
325+
classCallCheck(this, Store);
337326

338327
this._getterCacheId = 'vuex_store_' + uid++;
339328
this._dispatching = false;
@@ -357,7 +346,9 @@
357346
var silent = Vue.config.silent;
358347
Vue.config.silent = true;
359348
this._vm = new Vue({
360-
data: state
349+
data: {
350+
state: state
351+
}
361352
});
362353
Vue.config.silent = silent;
363354
this._setupModuleState(state, modules);
@@ -376,7 +367,7 @@
376367
* @return {Object}
377368
*/
378369

379-
babelHelpers.createClass(Store, [{
370+
createClass(Store, [{
380371
key: 'dispatch',
381372

382373

@@ -393,7 +384,7 @@
393384

394385
var silent = false;
395386
// compatibility for object actions, e.g. FSA
396-
if ((typeof type === 'undefined' ? 'undefined' : babelHelpers.typeof(type)) === 'object' && type.type && arguments.length === 1) {
387+
if ((typeof type === 'undefined' ? 'undefined' : _typeof(type)) === 'object' && type.type && arguments.length === 1) {
397388
payload = [type.payload];
398389
if (type.silent) silent = true;
399390
type = type.type;
@@ -405,10 +396,10 @@
405396
// apply the mutation
406397
if (Array.isArray(mutation)) {
407398
mutation.forEach(function (m) {
408-
return m.apply(undefined, [state].concat(babelHelpers.toConsumableArray(payload)));
399+
return m.apply(undefined, [state].concat(toConsumableArray(payload)));
409400
});
410401
} else {
411-
mutation.apply(undefined, [state].concat(babelHelpers.toConsumableArray(payload)));
402+
mutation.apply(undefined, [state].concat(toConsumableArray(payload)));
412403
}
413404
this._dispatching = false;
414405
if (!silent) this._applyMiddlewares(type, payload);
@@ -422,18 +413,22 @@
422413
* Same API as Vue's $watch, except when watching a function,
423414
* the function gets the state as the first argument.
424415
*
425-
* @param {String|Function} expOrFn
416+
* @param {Function} fn
426417
* @param {Function} cb
427418
* @param {Object} [options]
428419
*/
429420

430421
}, {
431422
key: 'watch',
432-
value: function watch(expOrFn, cb, options) {
423+
value: function watch(fn, cb, options) {
433424
var _this2 = this;
434425

426+
if (typeof fn !== 'function') {
427+
console.error('Vuex store.watch only accepts function.');
428+
return;
429+
}
435430
return this._vm.$watch(function () {
436-
return typeof expOrFn === 'function' ? expOrFn(_this2.state) : _this2._vm.$get(expOrFn);
431+
return fn(_this2.state);
437432
}, cb, options);
438433
}
439434

@@ -523,7 +518,7 @@
523518

524519
var Watcher = getWatcher(this._vm);
525520
/* eslint-disable no-new */
526-
new Watcher(this._vm, '$data', function () {
521+
new Watcher(this._vm, 'state', function () {
527522
if (!_this3._dispatching) {
528523
throw new Error('[vuex] Do not mutate vuex store state outside mutation handlers.');
529524
}
@@ -596,7 +591,7 @@
596591
}, {
597592
key: 'state',
598593
get: function get() {
599-
return this._vm._data;
594+
return this._vm.state;
600595
},
601596
set: function set(v) {
602597
throw new Error('[vuex] Vuex root state is read only.');

0 commit comments

Comments
 (0)