-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-10381] Fix waiting for last sync - Browser Refresh (#10438)
* [PM-10381] Add activeUserLastSync$ to SyncService * [PM-10381] Introduce waitUtil operator * [PM-10381] Use new activeUserLastSync$ observable to wait until a sync completes before attempting to get decrypted ciphers * [PM-10381] Fix failing test --------- Co-authored-by: bnagawiecki <[email protected]>
- Loading branch information
1 parent
bbe64f4
commit a8edce2
Showing
5 changed files
with
63 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
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,30 @@ | ||
import { | ||
merge, | ||
MonoTypeOperatorFunction, | ||
Observable, | ||
ObservableInput, | ||
sample, | ||
share, | ||
skipUntil, | ||
take, | ||
} from "rxjs"; | ||
|
||
/** | ||
* Operator that waits until the trigger observable emits before allowing the source to continue emission. | ||
* @param trigger$ The observable that will trigger the source to continue emission. | ||
* | ||
* ``` | ||
* source$ a-----b-----c-----d-----e | ||
* trigger$ ---------------X--------- | ||
* output$ ---------------c--d-----e | ||
* ``` | ||
*/ | ||
export const waitUntil = <T>(trigger$: ObservableInput<any>): MonoTypeOperatorFunction<T> => { | ||
return (source: Observable<T>) => { | ||
const sharedSource$ = source.pipe(share()); | ||
return merge( | ||
sharedSource$.pipe(sample(trigger$), take(1)), | ||
sharedSource$.pipe(skipUntil(trigger$)), | ||
); | ||
}; | ||
}; |
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