Created
May 3, 2013 10:56
-
-
Save heikela/5508499 to your computer and use it in GitHub Desktop.
This file contains 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.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