Skip to content

Instantly share code, notes, and snippets.

@maryrosecook
Created August 14, 2011 15:01
Show Gist options
  • Save maryrosecook/1144952 to your computer and use it in GitHub Desktop.
Save maryrosecook/1144952 to your computer and use it in GitHub Desktop.
Examples for Snowflake.js
var s = new Snowflake();
s.aSnowflakeFunc(supportingVar, actionFunc(arg) {
// do stuff in here.
}, arg);
s.change([watchVar1, watchVar2], function(optionalArgument) {
// do something
}, optionalArgument);
s.every(interval, function(optionalArgument) {
// do something
}, optionalArgument);
s.once(function(optionalArgument) {
// do something
}, optionalArgument);
// import Snowflake
var s = new Snowflake();
var problemFunc = function() {
var interestingVar = 0;
// insert function machinations here
// print out interestingVar once, even if problemFunc run > once
s.once(function() {
console.log(interestingVar);
});
// print out interestingVar every two seconds
// you can pass in an argument to your function, if you like
s.every(2, function(self) {
console.log(self.otherVar, interestingVar);
}, this);
// print out interestingVar if it has not changed since the last run
s.stuck([interestingVar], function() {
console.log(interestingVar);
});
}
s.stuck([watchVar1, watchVar2], function(optionalArgument) {
// do something
}, optionalArgument);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment