transform
Returns a Worker that transforms this Worker's Flow by calling transform.
The returned worker is considered equivalent with any other worker returned by this function with the same receiver.
Examples
Workers from the same source are equivalent
val secondsWorker = millisWorker.transform {
it.map { millis -> millis / 1000 }.distinctUntilChanged()
}
val otherSecondsWorker = millisWorker.transform {
it.map { millis -> millis.toSeconds() }
}
assert(secondsWorker.doesSameWorkAs(otherSecondsWorker))
Content copied to clipboard
Workers from different sources are not equivalent
val secondsWorker = millisWorker.transform {
it.map { millis -> millis / 1000 }.distinctUntilChanged()
}
val otherSecondsWorker = secondsWorker.transform { it }
assert(!secondsWorker.doesSameWorkAs(otherSecondsWorker))
Content copied to clipboard