Comparing version 0.7.1 to 0.7.2
@@ -139,3 +139,13 @@ 'use strict'; | ||
} | ||
// override to provide conditional logic | ||
// for whether a component's loop should receive | ||
// state updates | ||
}, { | ||
key: 'shouldUpdate', | ||
value: function shouldUpdate(state) { | ||
return true; | ||
} | ||
}, { | ||
key: 'update', | ||
@@ -146,3 +156,3 @@ value: function update() { | ||
if (!this.initialized) { | ||
this.state = Object.assign({}, this.state, stateUpdate); | ||
Object.assign(this.state, stateUpdate); | ||
} else if (this.isPanelRoot) { | ||
@@ -164,24 +174,26 @@ var updateHash = '$fragment' in stateUpdate && stateUpdate.$fragment !== this.state.$fragment; | ||
value: function updateSelfAndChildren(state) { | ||
this.loop.update(state); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
if (this.initialized && this.shouldUpdate(state)) { | ||
this.loop.update(state); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = this.$panelChildren[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var child = _step.value; | ||
try { | ||
for (var _iterator = this.$panelChildren[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var child = _step.value; | ||
child.updateSelfAndChildren(state); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
child.updateSelfAndChildren(state); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
@@ -188,0 +200,0 @@ } |
@@ -89,5 +89,12 @@ import MainLoop from 'main-loop'; | ||
// override to provide conditional logic | ||
// for whether a component's loop should receive | ||
// state updates | ||
shouldUpdate(state) { | ||
return true; | ||
} | ||
update(stateUpdate={}) { | ||
if (!this.initialized) { | ||
this.state = Object.assign({}, this.state, stateUpdate); | ||
Object.assign(this.state, stateUpdate); | ||
} else if (this.isPanelRoot) { | ||
@@ -108,5 +115,7 @@ const updateHash = '$fragment' in stateUpdate && stateUpdate.$fragment !== this.state.$fragment; | ||
updateSelfAndChildren(state) { | ||
this.loop.update(state); | ||
for (let child of this.$panelChildren) { | ||
child.updateSelfAndChildren(state); | ||
if (this.initialized && this.shouldUpdate(state)) { | ||
this.loop.update(state); | ||
for (let child of this.$panelChildren) { | ||
child.updateSelfAndChildren(state); | ||
} | ||
} | ||
@@ -113,0 +122,0 @@ } |
{ | ||
"name": "panel", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Web Components with Virtual DOM: lightweight composable web apps", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -55,4 +55,6 @@ [](https://travis-ci.org/mixpanel/panel) | ||
A brief tutorial is available in the [example](https://github.com/mixpanel/panel/tree/master/example) directory. The sample app accompanying the tutorial features routing, Jade templating, and infrastructure for practical usage such as Webpack/Babel configuration and inclusion of a Web Components polyfill. | ||
See [examples/](https://github.com/mixpanel/panel/tree/master/examples). | ||
A brief tutorial is available in the [examples/tutorial](https://github.com/mixpanel/panel/tree/master/examples/tutorial) directory. The sample app accompanying the tutorial features routing, Jade templating, and infrastructure for practical usage such as Webpack/Babel configuration and inclusion of a Web Components polyfill. | ||
A Panel implementation of the [TodoMVC](http://todomvc.com/) app spec is available at [https://github.com/tdumitrescu/todomvc-panel](https://github.com/tdumitrescu/todomvc-panel). | ||
@@ -59,0 +61,0 @@ |
56117
29
927
79