feat: instance-scoped "global" configuration#1315
Merged
B4nan merged 2 commits intoapify:masterfrom Mar 15, 2022
barjin:feat/alsConfiguration
Merged
feat: instance-scoped "global" configuration#1315B4nan merged 2 commits intoapify:masterfrom barjin:feat/alsConfiguration
B4nan merged 2 commits intoapify:masterfrom
barjin:feat/alsConfiguration
Conversation
…config Using `asyncLocalStorage`, `Configuration.getGlobalConfig()` now returns instance-scoped configuration (`sdk.config`). fixes #1305
B4nan
approved these changes
Mar 15, 2022
mnmkng
reviewed
Mar 15, 2022
Comment on lines
+312
to
+315
| return Configuration.storage.getStore() ?? (() => { | ||
| Configuration.globalConfig ??= new Configuration(); | ||
| return Configuration.globalConfig; | ||
| })(); |
Member
There was a problem hiding this comment.
Could this be written "normally"? 😄 I mean, it's kinda cool, but going from ?? into an IIFE is a bit hardcore.
Member
There was a problem hiding this comment.
its not that hardcore, but that IIFE made me smile too :D
Member
Author
There was a problem hiding this comment.
I paid for the whole JS grammar, I’m using the whole JS grammar!
But understood, I already hate it :) hope it is still legible enough at least
Member
There was a problem hiding this comment.
i gave green light because to me it is readable enough, its actually quite smart way to do this on so few lines. but we can be more readable for sure:
if (Configuration.storage.getStore()) {
return Configuration.storage.getStore();
}
Configuration.globalConfig ??= new Configuration();
return Configuration.globalConfig;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Using
asyncLocalStorage,Configuration.getGlobalConfig()now returns instance-scoped configuration (sdk.config).fixes #1305