All Downloads are FREE. Search and download functionalities are using the official Maven repository.

js.RT.Channel.observable.js Maven / Gradle / Ivy

The newest version!

	RT.Channel.prototype.observable = function(changeId, cfg){
		
		
		if (typeof(ko) === "undefined")
			throw "knockoutjs required for Observable feature";

		var o = ko.observable();
		
		//Register observable listener
		this.on(changeId, function(e){
			
			var value = e;
			
			//Filter event
			if (cfg && typeof cfg.filter === "function" && !cfg.filter(value))
				return;
			
			//Dereference event
			if (cfg && typeof cfg.accessor === "function")
				value = cfg.accessor(value);
			
			
			//Set new value
			o(value);
		});
		
		return o;
			
	};




© 2015 - 2025 Weber Informatics LLC | Privacy Policy