Skip to content

Instantly share code, notes, and snippets.

@andschdk
andschdk / SerialPresenter.swift
Last active March 14, 2019 01:02
Simple protocol to ensure only one item is presented at a time. It is based on the Rx `.zip` operator. As an example it is used for presenting alerts one at a time. This is great when dealing with arbitrary number of alerts that can appear because of uncontrollable factors such as errors.
import RxSwift
public protocol SerialPresenter {
associatedtype T
var incoming: Observable<T> { get }
var dismissCurrent: Observable<Void> { get }
var present: Observable<T> { get }
}