sindresorhus/p-min-delay

Delaying rejections

davidtheclark opened this issue · 1 comments

@sindresorhus: You noted in Gitter, "I deliberately did not make a rejected promise delay as I don’t really see the use-case of that, but happy to add an option if there are any use-cases." Thought I'd follow up via issues.

The use-cases I had in mind for this minimum delay seem (to me) to apply to both resolution and rejection. Here's a situation: A UI for validating files. Files can be a wide range of sizes, so validation might be nearly instantaneous or several seconds. When validation starts, the UI changes and you see a box with text "Validating file" and some kind of spinner. When validation ends, that goes away and you see either a success or error message. My goal in delaying the validation Promise is to prevent the "Validating file" UI state from flashing for fewer than one second, because that looks kind of janky and some users interpret it as a bug and worry that they missed something important. I don't want the "Validating file" UI state to flash whether it results in success or failure, because the flashing is equally unpleasant either way.

What do you think?

Thanks for chiming in. Your use-case makes sense. See: #3