LearnNewsExamplesServices
Frontmatter
id5430
titleShorten class exports for singleton files
stateClosed
labels
enhancement
assigneestobiu
createdAtJun 22, 2024, 10:50 AM
updatedAtJun 22, 2024, 3:10 PM
githubUrlhttps://github.com/neomjs/neo/issues/5430
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 22, 2024, 3:10 PM

Shorten class exports for singleton files

Closed v8.1.0 enhancement
tobiu
tobiu commented on Jun 22, 2024, 10:50 AM

I guess this one is a bit controversial. file size VS readability.

for a normal class we are doing:

Neo.setupClass(ServiceBase);

export default ServiceBase;

for a singleton it changes to:

let instance = Neo.setupClass(App);

export default instance;

=> setupClass() will return an instance if (and only if) the singleton config is set to true.

while the code will shorten when getting minified:

let i = Neo.setupClass(App);

export default i;

i would still prefer:

export default Neo.setupClass(App);

rationale: you don't define variables for things you only use once.

tobiu added the enhancement label on Jun 22, 2024, 10:50 AM
tobiu assigned to @tobiu on Jun 22, 2024, 10:50 AM
tobiu referenced in commit 4d8fdd2 - "Shorten class exports for singleton files #5430" on Jun 22, 2024, 11:08 AM
tobiu closed this issue on Jun 22, 2024, 3:10 PM