Example #1
0
	compute: function () {
		var ractive, errored, newDependencies;

		ractive = this.ractive;
		ractive.viewmodel.capture();

		try {
			this.value = this.getter.call( ractive );
		} catch ( err ) {

			log.warn({
				debug: ractive.debug,
				message: 'failedComputation',
				args: {
					key: this.key,
					err: err.message || err
				}
			});

			errored = true;
		}

		newDependencies = ractive.viewmodel.release();
		diff( this, this.dependencies, newDependencies );

		return errored ? false : true;
	},
Example #2
0
	getValue: function () {
		var args, value, newImplicitDependencies;

		args = this.argumentGetters.map( call );

		if ( this.updating ) {
			// Prevent infinite loops caused by e.g. in-place array mutations
			return;
		}

		this.updating = true;

		this.viewmodel.capture();

		try {
			value = this.fn.apply( null, args );
		} catch ( err ) {
			if ( this.root.debug ) {
				log.warn({
					debug: this.root.debug,
					message: 'evaluationError',
					args: {
						uniqueString: this.uniqueString,
						err: err.message || err
					}
				});
			}

			value = undefined;
		}

		newImplicitDependencies = this.viewmodel.release();
		diff( this, this.dependencies, newImplicitDependencies );

		this.updating = false;

		return value;
	},