-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fbaa51
commit fbf5ca0
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
The `waitFor(...)` helper function, which asynchronously _waits_ for an actor's emitted value to satisfy a `predicate` before a `timeout`, is now available. | ||
|
||
Example usage: | ||
|
||
```js | ||
import { waitFor } from 'xstate/lib/waitFor'; | ||
|
||
// ... | ||
const loginService = interpret(loginMachine).start(); | ||
|
||
const loggedInState = await waitFor(loginService, (state) => | ||
state.hasTag('loggedIn') | ||
); | ||
|
||
loggedInState.hasTag('loggedIn'); // true | ||
``` |