refactor(main): simplify _updateDom with async/await#4185
Merged
khassel merged 1 commit intoJun 12, 2026
Conversation
Collaborator
|
Cool, that was a head scratcher. Trouble caused long before await |
Collaborator
Author
|
I'm glad you like it. And kudos to everyone who set this up and managed to make sense of such pre-async/await patterns 🤯 |
khassel
approved these changes
Jun 12, 2026
KristjanESPERANTO
added a commit
to KristjanESPERANTO/MagicMirror
that referenced
this pull request
Jun 12, 2026
…4185) `_updateDom` was wrapping its entire body in a `new Promise(resolve => {...})` constructor just to chain `getDom()` and `updateDomWithContent()` together. Since `updateDomWithContent` was already converted to async in MagicMirrorOrg#4182, we can now just `await` it directly - the manual wrapper, the explicit `Promise.resolve()` normalization, and the nested `.then().catch()` chain all become unnecessary, making the control flow easier to follow. Also added `.catch(Log.error)` at both call sites, since async functions reject on error instead of swallowing it silently.
KristjanESPERANTO
added a commit
to KristjanESPERANTO/MagicMirror
that referenced
this pull request
Jun 12, 2026
…4185) `_updateDom` was wrapping its entire body in a `new Promise(resolve => {...})` constructor just to chain `getDom()` and `updateDomWithContent()` together. Since `updateDomWithContent` was already converted to async in MagicMirrorOrg#4182, we can now just `await` it directly - the manual wrapper, the explicit `Promise.resolve()` normalization, and the nested `.then().catch()` chain all become unnecessary, making the control flow easier to follow. Also added `.catch(Log.error)` at both call sites, since async functions reject on error instead of swallowing it silently.
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.
_updateDomwas wrapping its entire body in anew Promise(resolve => {...})constructor just to chaingetDom()andupdateDomWithContent()together. SinceupdateDomWithContentwas already converted to async in #4182, we can now justawaitit directly - the manual wrapper, the explicitPromise.resolve()normalization, and the nested.then().catch()chain all become unnecessary, making the control flow easier to follow.Also added
.catch(Log.error)at both call sites, since async functions reject on error instead of swallowing it silently.