-
-
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.
* Allow passing `Infinity` to as `waitFor` timeout * Add changeset * Add dev warning for negative timeouts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Format * Add test * Simplify casting situation in `waitFor` * Update .changeset/cool-ducks-pretend.md Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
1 parent
7a698d4
commit 44c66e7
Showing
3 changed files
with
58 additions
and
5 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': patch | ||
--- | ||
|
||
Removing the timeout that's built in to `waitFor` is now supported by explicitly passing an `Infinity` value. | ||
|
||
Example usage: | ||
|
||
```js | ||
import { waitFor } from 'xstate/lib/waitFor'; | ||
|
||
// This will | ||
const loggedInState = await waitFor( | ||
loginService, | ||
(state) => state.hasTag('loggedIn'), | ||
{ timeout: Infinity } | ||
); | ||
``` | ||
|
||
This fixes a bug that causes `waitFor` to reject with an error immediately due to the behaviour of `setTimeout`. |
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
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