mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Add more doc
on why module level variables do not work as singletons
This commit is contained in:
parent
a012dbafce
commit
81871c50be
1 changed files with 3 additions and 0 deletions
|
@ -84,6 +84,9 @@ class Skinner {
|
||||||
// behaviour with multiple copies of files etc. is erratic at best.
|
// behaviour with multiple copies of files etc. is erratic at best.
|
||||||
// XXX: We can still end up with the same file twice in the resulting
|
// XXX: We can still end up with the same file twice in the resulting
|
||||||
// JS bundle which is nonideal.
|
// JS bundle which is nonideal.
|
||||||
|
// See https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
|
||||||
|
// or https://nodejs.org/api/modules.html#modules_module_caching_caveats
|
||||||
|
// ("Modules are cached based on their resolved filename")
|
||||||
if (global.mxSkinner === undefined) {
|
if (global.mxSkinner === undefined) {
|
||||||
global.mxSkinner = new Skinner();
|
global.mxSkinner = new Skinner();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue