...
Code Block |
---|
language | js |
---|
title | Simple event Lazy-loaded namespace |
---|
|
EventNamespace: 'app.domain'
EventAttribute: '$ app.domain.function(eventSource);' |
...
Code Block |
---|
language | js |
---|
title | Event Lazy-loaded namespace with automatic namespacedetection |
---|
|
EventNamespace: 'app.domain'
EventAttribute: '$ eventNamespace.function(eventSource);' |
The last mentioned issue with the centralized logic was the polluted global scope.
To keep the global context clean, the '#' reserved namespace was introduced.
By using it, the namespace is loaded into the object at runtime, but is never exposed outside of it:
Code Block |
---|
language | js |
---|
title | Encapsulated lazy-loaded namespace |
---|
|
EventNamespace: '#'
EventAttribute: '$ #.function(eventSource);' |