-
-
Save pyrtsa/5512257 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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