Function useWaitable

Creates a waitable associated with a primary function that is given responsibility for updating the success and/or failure states of the waitable.

The primary function receives callbacks for setting the success and failure states of the waitable. These can be called any number of times. However, the primary function itself will only be called once if a reset isn't issued on the waitable. The waitable is considered busy until the function itself is complete -- though it's allowed that the setSuccess and setFailure functions can be called even after the primary function is complete. If a reset occurs, any calls to previously created setSuccess/setFailure callbacks are ignored.

If a primary function throws, the waitable will no longer be busy, but the state won't otherwise change and the primary function won't automatically be rerun.

During default value generation, if an error occurs, either thrown or via setFailure if using defaultValue='use-primary-function' or defaultValue='use-primary-function-if-unlocked', reset('soft') is automatically called so the primary function can be run again as applicable.