Use joliCreator function to allow multiple db instances; Add to exports var instead of replacing it. #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This looks like a big change via the diff, but there's no change between from the previous
var joli = { ... }
, it's just wrapped in a newjoliCreator()
function now. There's a second small change at the end to make CommonJS work -- instead of replacing theexports
object, we need to add properties to it. I don't know if replacingexports
worked in 1.7.x, but it doesn't work in 1.8.x.The two changes are:
For CommonJS usage, a single
var joli
in the module doesn't work if you want multiple db instances. Subsequentrequire('joli').connect()
s will overwrite previous connection since they're using the same joli var in the module. Instead, a newjoliCreator()
function is used that will return a new joli object on each call. For parity withTi.include()
, create a module joli var with this function right away. This allows us to have multiple joli connections with CommonJS usage.CommonJS usage shouldn't replace the entire exports object, it should add to the object as needed. (https://jira.appcelerator.org/browse/TIMOB-5406)