RxJava替代map()运算符来保存发出的项目

Tud*_*uca 5 android rx-java retrofit

我使用Retrofit与REST API交互,RxJava操作我收到的数据.

在下面的代码片段中,我进行了API调用,并使用map运算符保存我收到的数据,然后继续对流进行其他操作.

retrofitApi.registerDevice(mDevice)
           .map(new Func1<Device, Device>() {
               @Override
               public Device call(Device device) {
                  // The only purpose of the map() operator 
                  // is to save the received device.
                  magicBox.saveDeviceId(device.getId());
                  return device;
               }
           })
           .otherOperations()...
Run Code Online (Sandbox Code Playgroud)

我的问题是:这个工作有更好的操作员吗?我觉得我误用了map操作员.

Tud*_*uca 7

根据叶戈尔的回答,我做了一些研究,根据Dan Lew的博客文章这个问题,正确的答案似乎是 doOnNext.