remove _flush in favour of callAll

pull/705/head
Rich Harris 8 years ago
parent e9f17f34ff
commit 84e6d0c5b7

@ -122,8 +122,8 @@ export default function dom(
@dispatchObservers( this, this._observers.pre, newState, oldState ); @dispatchObservers( this, this._observers.pre, newState, oldState );
${block.hasUpdateMethod && `this._fragment.update( newState, this._state );`} ${block.hasUpdateMethod && `this._fragment.update( newState, this._state );`}
@dispatchObservers( this, this._observers.post, newState, oldState ); @dispatchObservers( this, this._observers.post, newState, oldState );
${(generator.hasComponents || generator.hasComplexBindings) && ${generator.hasComponents && `@callAll(this._oncreate);`}
`this._flush();`} ${generator.hasComplexBindings && `@callAll(this._bindings);`}
${generator.hasIntroTransitions && `@callAll(this._postcreate);`} ${generator.hasIntroTransitions && `@callAll(this._postcreate);`}
`; `;
@ -157,7 +157,7 @@ export default function dom(
? `@proto ` ? `@proto `
: deindent` : deindent`
{ {
${['get', 'fire', 'observe', 'on', 'set', '_flush'] ${['get', 'fire', 'observe', 'on', 'set']
.map(n => `${n}: @${n}`) .map(n => `${n}: @${n}`)
.join(',\n')} .join(',\n')}
}`; }`;
@ -218,16 +218,15 @@ export default function dom(
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null ); this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null );
} }
${(generator.hasComponents || generator.hasIntroTransitions || generator.hasComplexBindings || templateProperties.oncreate) && ${generator.hasComponents && `@callAll(this._oncreate);`}
`this._flush();`} ${generator.hasComplexBindings && `@callAll(this._bindings);`}
${templateProperties.oncreate && ${templateProperties.oncreate && deindent`
deindent` if ( options._root ) {
if ( options._root ) { options._root._oncreate.push( @template.oncreate.bind( this ) );
options._root._oncreate.push( @template.oncreate.bind( this ) ); } else {
} else { @template.oncreate.call( this );
@template.oncreate.call( this ); }`}
}`}
${generator.hasIntroTransitions && `@callAll(this._postcreate);`} ${generator.hasIntroTransitions && `@callAll(this._postcreate);`}
} }

@ -106,25 +106,19 @@ export function onDev(eventName, handler) {
export function set(newState) { export function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
export function callAll(fns) { export function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
export function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
export var proto = { export var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
export var protoDev = { export var protoDev = {
@ -132,6 +126,5 @@ export var protoDev = {
fire: fire, fire: fire,
observe: observeDev, observe: observeDev,
on: onDev, on: onDev,
set: set, set: set
_flush: _flush
}; };

@ -115,25 +115,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
var template = (function () { var template = (function () {

@ -91,25 +91,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
function recompute ( state, newState, oldState, isInitial ) { function recompute ( state, newState, oldState, isInitial ) {

@ -124,25 +124,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
function create_main_fragment ( state, component ) { function create_main_fragment ( state, component ) {

@ -109,25 +109,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
var template = (function () { var template = (function () {

@ -115,25 +115,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
function create_main_fragment ( state, component ) { function create_main_fragment ( state, component ) {

@ -115,25 +115,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
function create_main_fragment ( state, component ) { function create_main_fragment ( state, component ) {

@ -103,25 +103,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
var template = (function () { var template = (function () {
@ -193,7 +187,7 @@ function SvelteComponent ( options ) {
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} }
this._flush(); callAll(this._oncreate);
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
@ -203,7 +197,7 @@ SvelteComponent.prototype._set = function _set ( newState ) {
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
this._flush(); callAll(this._oncreate);
}; };
SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) {

@ -1,6 +1,6 @@
import Imported from 'Imported.html'; import Imported from 'Imported.html';
import { assign, createText, detachNode, dispatchObservers, insertNode, proto } from "svelte/shared.js"; import { assign, callAll, createText, detachNode, dispatchObservers, insertNode, proto } from "svelte/shared.js";
var template = (function () { var template = (function () {
return { return {
@ -71,7 +71,7 @@ function SvelteComponent ( options ) {
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} }
this._flush(); callAll(this._oncreate);
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
@ -81,7 +81,7 @@ SvelteComponent.prototype._set = function _set ( newState ) {
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
this._flush(); callAll(this._oncreate);
}; };
SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) {

@ -91,25 +91,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
var template = (function () { var template = (function () {
@ -156,8 +150,6 @@ function SvelteComponent ( options ) {
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} }
this._flush();
if ( options._root ) { if ( options._root ) {
options._root._oncreate.push( template.oncreate.bind( this ) ); options._root._oncreate.push( template.oncreate.bind( this ) );
} else { } else {

@ -44,8 +44,6 @@ function SvelteComponent ( options ) {
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} }
this._flush();
if ( options._root ) { if ( options._root ) {
options._root._oncreate.push( template.oncreate.bind( this ) ); options._root._oncreate.push( template.oncreate.bind( this ) );
} else { } else {

@ -115,25 +115,19 @@ function on(eventName, handler) {
function set(newState) { function set(newState) {
this._set(assign({}, newState)); this._set(assign({}, newState));
this._root._flush(); callAll(this._root._oncreate);
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.pop()();
} }
function _flush() {
callAll(this._oncreate);
callAll(this._bindings);
}
var proto = { var proto = {
get: get, get: get,
fire: fire, fire: fire,
observe: observe, observe: observe,
on: on, on: on,
set: set, set: set
_flush: _flush
}; };
function create_main_fragment ( state, component ) { function create_main_fragment ( state, component ) {

Loading…
Cancel
Save