Created
October 14, 2011 15:46
-
-
Save Enome/1287463 to your computer and use it in GitHub Desktop.
Class that watches a knockout.js viewmodel for changes.
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
class Observer | |
constructor : (data, fn, ignore=[])-> | |
@listen = false | |
result = ko.dependentObservable -> | |
for key, val of data | |
if ko.isObservable(val) and key not in ignore | |
val() | |
result.subscribe => | |
if @listen | |
fn() | |
start : -> @listen = true | |
stop : -> @listen = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment