[TIMOB-12648] TiAPI: Create a "global" variable
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | TiAPI |
Labels | n/a |
Reporter | Bryan Hughes |
Assignee | Unknown |
Created | 2013-02-08T21:38:21.000+0000 |
Updated | 2018-02-28T20:04:27.000+0000 |
Description
Sharing variables between modules is complex. The proper way is to use an intermediary to pass the values back and forth, but this is a lot of effort for something simple. Some platforms simply reuse the same context for all modules (this is undocumented), but that is a bad idea for both performance reasons and because it increases the chance of nasty bugs.
The proper way is to have some variable in the "module" scope that allows access to the true global scope. There is plenty of precedence for this because browsers have the "window" object and node.js has the "global" object that references the "true" global scope.
We should do something similar and provide a "global" object.
IMHO - sharing variables between CommonJS modules is ... not so hard. :) Community devs use "global" (so to say) module and require it where it is needed.
Backlog? :(