The function returned by $Y (the wrapping function) meets the following requirements:
Any function passed to the when() method of jsx3.$AsyncRV is called when the asynchronous method is done.
The function is passed a single parameter, which is the asynchronous return value of the asynchronous function, as in the following example:
A program can call when() any number of times before or after the asynchronous method finishes. Regardless of when it is called, all callbacks are invoked. For example:
Use the and() and or() methods of jsx3.$AsyncRV to chain asynchronous return conditions. Both methods also return instances of jsx3.$AsyncRV. For example:
If an instance of jsx3.$AsyncRV is passed as a parameter to an asynchronous function, the function automatically waits for the parameter to be available before calling the wrapped function.
This can eliminate a call to when() and an anonymous function, thereby improving code readability and conciseness.
The previous code is equivalent to but more concise than the following code.