Skip to content

Commit

Permalink
Add changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Apr 6, 2022
1 parent 6fbaa51 commit fbf5ca0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .changeset/bright-cougars-bake.md
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
```

0 comments on commit fbf5ca0

Please sign in to comment.