O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom classes

If we are working with some complex data that needs to be reused in multiple steps, it often makes sense to create our own custom classes. It is a very lightweight approach and what's even better--it's very explicit.

With custom classes, it is easy to describe the data passed--it will be the name of the class. For example, the user object + accessToken can become UserCredentials and will look like this:

class User {    String userId;    public User(String userId) {       this.userId = userId;    }}class UserCredentials {    public final User user;    public final String accessToken;    public UserCredentials(User user, String accessToken) {        this.user = user;        this.accessToken = accessToken;    }}

This way, the data in later operations can be accessed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required