WaitFor
Sometimes when doing Server Side Rendering (SSR) or testing your logic, you might
want to await for an action. This is what the kea-waitfor
plugin does!
Keep In Mind
kea-waitfor in not (YET!) designed to be used in listeners. Only use it outside your logic,
like in tests or in a Server Side Rendering context.
However, if you're feeling lucky and use it anyway in a listener, remember to add a breakpoint after the wait!
Installation#
First install the kea-waitfor package:
Then install the plugin:
waitForAction#
To wait for a kea action, use waitForAction:
For example:
waitForCondition#
To wait for any random condition, use waitForCondition:
For example:
Wait for many events#
All events finish#
To wait for multiple actions to finish, use Promise.all like you would with other
promises:
First event#
To wait for the first action to finish, use Promise.race:
First event with metadata#
To add more metadata to better detect the winning action, feel free to
add .then(...) to the promises:
With a timeout#
To wait with a timeout, use a makeshift timebomb: