The maybe trait

Maybe is a mix of single and completable. It can emit a single next event, a completed event, or an error event. In other words, it can either emit an element or error and be done or emit a completed event without emitting anything else. Like single and completable, it does not replay, and we can convert a raw Observable sequence to a maybe by calling asMaybe() on it. A maybe can be used just like a single in places where it might be possible that it won't emit an element or an error and could just complete.

Get Reactive Programming with Swift 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.