Problem Statement
Explain common Flow operators and when to use each for transforming asynchronous streams.
Explanation
Map transforms each emitted value like collection map but asynchronously, filter selects values based on predicates, and transform provides full control to emit zero or multiple values per input. Use map for one-to-one transformations, filter to skip unwanted values, and transform for flexible emission patterns.
Catch handles upstream exceptions allowing recovery or fallback emissions, onEach performs side effects for each value without transforming it, and combine merges multiple Flows emitting whenever any source emits. Combine is useful for combining UI state from multiple sources.
Buffer controls backpressure by allowing emissions to continue while collection is slow, conflate keeps only the latest value dropping intermediate ones, and collectLatest cancels previous collection when new value arrives. Use conflate for rapidly changing state where intermediate values don't matter.
Debounce emits only after a quiet period, useful for search queries where you want to wait until typing stops. FlatMapConcat, flatMapMerge, and flatMapLatest control how nested Flows are flattened, choosing between sequential, concurrent, or latest-only processing.
