Lock a function over several app instances or builds.
Inspired by the API of shepelt:locksmith. Couldn't find any repo with source, so I reimplemented.
TODO
// override default number of seconds to keep lock
// default: 60s
LockSmith.lockTTL = 3;
// setup an observer that can only run once over all instances
LockSmith.once("unique name of your lock", function() {
console.log('do something that can only run once');
Projects.find().observe({
'added': function() {
// all projects will only be added once
// even when you run multiple instance of your app
// or this source was built in multiple apps
console.log('added')
}
})
});
Licensed under the MIT License.