Created
March 11, 2016 14:54
-
-
Save julesbou/1e1db9871236a37418e2 to your computer and use it in GitHub Desktop.
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 db = { | |
// will be called only once | |
connect: _.once(function() { | |
/* .. do something .. */ | |
}), | |
find: function(id) { | |
// lazy connection | |
this.connect(); | |
return /* .. something .. */; | |
}, | |
findall: function() { | |
// lazy connection | |
this.connect(); | |
return /* .. something.. */; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment