How to use the metal.async.nextTick function in metal

To help you get started, we’ve selected a few metal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metal / metal.js / test / State.js View on Github external
it('should not throw error when trying to emit scheduled stateChanged after disposed', function(done) {
		var state = createStateInstance();

		state.key1 = 10;
		state.dispose();
		async.nextTick(function() {
			done();
		});
	});
github metal / metal.js / test / Attribute.js View on Github external
it('should not throw error when trying to emit scheduled attrsChanged after disposed', function(done) {
		var attr = createAttributeInstance();

		attr.attr1 = 10;
		attr.dispose();
		async.nextTick(function() {
			done();
		});
	});
github metal / metal.js / packages / metal-dom / src / globalEval.js View on Github external
static runScript(script, opt_callback, opt_appendFn) {
		const callback = function() {
			opt_callback && opt_callback();
		};
		if (script.type && script.type !== 'text/javascript') {
			async.nextTick(callback);
			return;
		}
		exitDocument(script);
		if (script.src) {
			return globalEval.runFile(script.src, opt_callback, opt_appendFn);
		} else {
			async.nextTick(callback);
			return globalEval.run(script.text, opt_appendFn);
		}
	}
github metal / metal.js / packages / metal-state / src / State.js View on Github external
scheduleBatchEvent_(changeData) {
		if (!this.scheduledBatchData_) {
			async.nextTick(this.emitBatchEvent_, this);
			this.scheduledBatchData_ = object.mixin({
				changes: {}
			}, this.eventData_);
		}

		const name = changeData.key;
		const changes = this.scheduledBatchData_.changes;
		if (changes[name]) {
			changes[name].newVal = changeData.newVal;
		} else {
			changes[name] = changeData;
		}
	}
github metal / metal.js / packages / metal-dom / src / globalEval.js View on Github external
static runScript(script, opt_callback, opt_appendFn) {
		const callback = function() {
			opt_callback && opt_callback();
		};
		if (script.type && script.type !== 'text/javascript') {
			async.nextTick(callback);
			return;
		}
		exitDocument(script);
		if (script.src) {
			return globalEval.runFile(script.src, opt_callback, opt_appendFn);
		} else {
			async.nextTick(callback);
			return globalEval.run(script.text, opt_appendFn);
		}
	}
github metal / metal.js / packages / metal-dom / src / globalEvalStyles.js View on Github external
if (
			style.rel &&
			style.rel !== 'stylesheet' &&
			style.rel !== 'canonical' &&
			style.rel !== 'alternate'
		) {
			async.nextTick(callback);
			return;
		}

		if (
			style.tagName === 'STYLE' ||
			style.rel === 'canonical' ||
			style.rel === 'alternate'
		) {
			async.nextTick(callback);
		} else {
			once(style, 'load', callback);
			once(style, 'error', callback);
		}

		if (appendFn) {
			appendFn(style);
		} else {
			document.head.appendChild(style);
		}

		return style;
	}
github metal / metal.js / packages / metal-dom / src / globalEval.js View on Github external
static runScriptsInElement(element, opt_callback, opt_appendFn) {
		const scripts = element.querySelectorAll('script');
		if (scripts.length) {
			globalEval.runScriptsInOrder(scripts, 0, opt_callback, opt_appendFn);
		} else if (opt_callback) {
			async.nextTick(opt_callback);
		}
	}
github metal / metal.js / src / Attribute.js View on Github external
scheduleBatchEvent_(attrChangeData) {
		if (!this.scheduledBatchData_) {
			async.nextTick(this.emitBatchEvent_, this);
			this.scheduledBatchData_ = {
				changes: {}
			};
		}

		var name = attrChangeData.attrName;
		var changes = this.scheduledBatchData_.changes;
		if (changes[name]) {
			changes[name].newVal = attrChangeData.newVal;
		} else {
			changes[name] = attrChangeData;
		}
	}
github metal / metal.js / packages / metal-dom / src / globalEvalStyles.js View on Github external
const callback = function() {
			if (opt_callback && ++loadCount === styles.length) {
				async.nextTick(opt_callback);
			}
		};
		for (let i = 0; i < styles.length; i++) {