Created
August 14, 2011 15:01
-
-
Save maryrosecook/1144952 to your computer and use it in GitHub Desktop.
Examples for Snowflake.js
This file contains hidden or 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 s = new Snowflake(); | |
s.aSnowflakeFunc(supportingVar, actionFunc(arg) { | |
// do stuff in here. | |
}, arg); |
This file contains hidden or 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
s.change([watchVar1, watchVar2], function(optionalArgument) { | |
// do something | |
}, optionalArgument); |
This file contains hidden or 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
s.every(interval, function(optionalArgument) { | |
// do something | |
}, optionalArgument); |
This file contains hidden or 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
s.once(function(optionalArgument) { | |
// do something | |
}, optionalArgument); |
This file contains hidden or 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
// 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); | |
}); | |
} |
This file contains hidden or 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
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