refactor: Create disableWhileProcessing helper function - #2126
Draft
marcustyphoon wants to merge 11 commits into
Draft
refactor: Create disableWhileProcessing helper function#2126marcustyphoon wants to merge 11 commits into
disableWhileProcessing helper function#2126marcustyphoon wants to merge 11 commits into
Conversation
disableWhileProcessing helper function
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.
Description
Just an idea. These are a little weird.
This creates helper functions for:
Merged in refactor: CreatewithErrorModal: "Wrap this function inshowErrorModalto catch errors when it's executed." I find this more clear than writing e.g.event => onButtonClicked(event).catch(showErrorModal). My guess is that this is probably uncontroversial? One question is, would we want to writewithErrorModal(someCallback)in the place where it's used, as I did here, or around someCallback where it's defined? The latter breaks jsdoc.withModalOnErrorhelper function #2129.disableWhileProcessing: "Disable a given UI element during the execution of this promise or this block of async code." This might be getting a bit too cute; it's a oneliner shorthand forwhatever.disabled = true; try { /* */ } finally { whatever.disabled = false; }.Notably, the way I wrote the latter involves executing the callback function given to the disableWhileProcessing helper, not returning it, so these can't be used as e.g.
withErrorModal(disableWhileProcessing(someElement, someCallback))/disableWhileProcessing(someElement, withErrorModal(someCallback)). That I can think of, you wouldn't generally be able to do this pattern anyway, becausesomeElementprobably isn't in scope outside of the callback.Testing steps
tbd