๐
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
| /* | |
| * Copyright 2025 Kyriakos Georgiopoulos | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
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() | |
| } | |
| } |
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
| import io.reactivex.rxjava3.core.Observable | |
| import io.reactivex.rxjava3.core.Scheduler | |
| import io.reactivex.rxjava3.core.Single | |
| import io.reactivex.rxjava3.kotlin.subscribeBy | |
| import io.reactivex.rxjava3.schedulers.Schedulers | |
| import java.util.* | |
| import java.util.concurrent.TimeUnit | |
| import java.util.concurrent.atomic.AtomicInteger | |
| import kotlin.math.pow | |
| import kotlin.random.Random |