Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// jQuery extensions
$.fn.valueAsObservable = function valueAsObservable() {
var changes = $(this).changeAsObservable();
var keyUps = $(this).keyupAsObservable();
var values = changes.merge(keyUps).map(function (e) {return e.target.value});
return values.distinctUntilChanged();
}
// Define some streams
var nameS = $('#user-info input[name=name]').valueAsObservable().subscribe(log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment