Maybe

An instance of the Maybe type can emit no value, or a single value. The following example code shows how to use Maybe and the test method:

Maybe.just(1)
.map { item -> item + 1 }
.filter { item -> item == 1 }
.defaultIfEmpty(4)
.test()
.assertResult(4)

The test method returns an instance of the TestObservable that is used for testing and contains methods such as assertResult. The defaultIfEmpty method of the Maybe class allows us to specify a default value that can be emitted if an instance of the Maybe class is empty.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.30.19