Skip to content

refactor: Create disableWhileProcessing helper function - #2126

Draft
marcustyphoon wants to merge 11 commits into
masterfrom
marcustyphoon/try-helpers
Draft

refactor: Create disableWhileProcessing helper function#2126
marcustyphoon wants to merge 11 commits into
masterfrom
marcustyphoon/try-helpers

Conversation

@marcustyphoon

@marcustyphoon marcustyphoon commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Description

Just an idea. These are a little weird.

This creates helper functions for:

  • withErrorModal: "Wrap this function in showErrorModal to 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 write withErrorModal(someCallback) in the place where it's used, as I did here, or around someCallback where it's defined? The latter breaks jsdoc. Merged in refactor: Create withModalOnError helper 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 for whatever.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, because someElement probably isn't in scope outside of the callback.

Testing steps

tbd

@marcustyphoon marcustyphoon changed the title refactor: Create helper functions for common try/catch and try/finally uses refactor: Create disableWhileProcessing helper function Mar 13, 2026
@marcustyphoon marcustyphoon self-assigned this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant