Skip to content

Instantly share code, notes, and snippets.

@hipertracker
Last active April 11, 2017 17:10
Show Gist options
  • Save hipertracker/8626365 to your computer and use it in GitHub Desktop.
Save hipertracker/8626365 to your computer and use it in GitHub Desktop.
Reactive Amplify (MeteorJS)
ReactiveAmplify = function () {
var self = this,
data = amplify.store(),
dataDep = new Deps.Dependency();
self.get = function (key) {
dataDep.depend();
return amplify.store(key)
};
self.set = function (key, value) {
data[key] = value;
amplify.store(key, value);
dataDep.changed();
};
self.setDefault = function (key, value) {
if (!data && !data[key])
self.set(key, value);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment