Nikita Kraev
Nikita Kraev

Reputation: 1129

Does RxJava map() return value on assignment?

I've got a code, like this:

Observable
    .create(...)
    .map(client -> localClient = client)
    .flatMap(client -> ...);

Does it just assigns "client" to some local instance "localClient" and returns it? Or i should explicitly write

Observable
    .create(...)
    .map(client -> {localClient = client; return client; })
    .flatMap(client -> ...);

Upvotes: 0

Views: 262

Answers (1)

tddmonkey
tddmonkey

Reputation: 21184

Your first snippet works as you want it to, the result of the assignment is returned so will become the client that is passed through the rest of your Rx chain.

Upvotes: 1

Related Questions