Finally, the Maybe type is very similar to the Single type, but the item might not be returned to the subscriber in the end.
The Maybe type can be created in a very similar fashion as before:
Maybe.empty();
Alternatively, it can be created as follows:
Maybe.just("Item");
However, the .subscribe() can be called with arguments dedicated to handling onSuccess (for received items), onError (to handle errors), and onComplete (to do a final action after the item is handled):
Maybe.just("Item")
.subscribe(
s -> log("success: " + s),
throwable -> log("error"),
() -> log("onComplete")
);