Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Knockout: Detatchable dependentObservable
// A dependentObservable that can be written to and reverted.
ko.detatchableDependentObservable = function(value, model) {
var root_value = typeof value === 'function' ? ko.dependentObservable(value, model) : ko.observable(value);
var public_value = ko.observable(root_value());
root_value.subscribe(function(value){
public_value(value);
});
var public_ = ko.dependentObservable({read: public_value, write: function(value){ public_.isConnected(false); public_value(value); }});
public_.isConnected = ko.observable(true);
public_.reconnect = function(){ this.isConnected(true); public_value(root_value()); };
public_.disconnect = function(){ this.isConnected(false); };
return public_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.