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.startWith($(this).val()).distinctUntilChanged();
}
// Define some streams
var nameS = $('#user-info input[name=name]').valueAsObservable().subscribe(log);
// Throttling (if rx.time.js is included)
var throttledNameS = nameS.throttle(1000); // milliseconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment