Created
March 24, 2023 03:05
-
-
Save hoangchungk53qx1/67d88e713c6de6a81c99924b86fe940f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| extension Publisher { | |
| // The flatMapLatest operator behaves much like the standard FlatMap operator, except that whenever | |
| // a new item is emitted by the source Publisher, it will unsubscribe to and stop mirroring the Publisher | |
| // that was generated from the previously-emitted item, and begin only mirroring the current one. | |
| func flatMapLatest<T: Publisher>(_ transform: @escaping (Self.Output) -> T) -> Publishers.SwitchToLatest<T, Publishers.Map<Self, T>> where T.Failure == Self.Failure { | |
| map(transform).switchToLatest() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment