-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing race condition preventing language from loading (#480)
Co-authored-by: Ole Martin Handeland <[email protected]>
- Loading branch information
1 parent
b7ceea6
commit 0bdb869
Showing
6 changed files
with
44 additions
and
26 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
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
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
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,27 @@ | ||
import { call, select, take } from 'redux-saga/effects'; | ||
import type { SagaIterator } from 'redux-saga'; | ||
|
||
import type { IRuntimeState } from 'src/types'; | ||
|
||
export function* waitForFunc( | ||
selector: (state: IRuntimeState) => boolean, | ||
): SagaIterator { | ||
if (yield select(selector)) { | ||
return; | ||
} | ||
while (true) { | ||
yield take('*'); | ||
if (yield select(selector)) { | ||
return; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* This saga effect allows you to wait for a specific state to change. It will wait for new actions to be dispatched | ||
* until your selector returns true, and it might be a safer way to wait than running yield take(...) on the action | ||
* you wanted to wait for (as this will return immediately if the state already is as expected, instead of waiting | ||
* for the event in question). | ||
*/ | ||
export const waitFor = (selector: (state: IRuntimeState) => boolean) => | ||
call(waitForFunc, selector); |