Created
March 18, 2013 18:57
-
-
Save sixolet/5189793 to your computer and use it in GitHub Desktop.
A way of isolating dependencies. Mostly a code sketch, may eventually be part of Meteor
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
var isolate = function (f) { | |
var dep = new Deps.Dependency(); | |
var result = Deps.nonreactive(f); | |
var computation = Deps.autorun(function () { | |
var newResult = f(); | |
if (!EJSON.equals(result, newResult)) { | |
dep.changed(); | |
computation.stop(); | |
result = newResult; | |
} | |
}); | |
Deps.depend(dep); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment