An idea for cross-process synchronization, liveData is observer based with a lifecycle pattern
Implementing cross-process synchronization is more lightweight
final CrossLiveData<AccountInfo> infoCrossLiveData = Retrofit.createApi(AccountApi.class).getAccountInfo().toSubProcess();
infoCrossLiveData.observe(this.new Observer<AccountInfo>() {
@Override
public void onChanged(AccountInfo accountInfo) {
if(tvAccountInfo == null) {return; } tvAccountInfo.setText(accountInfo.getName()); tvAccountInfo.setTextColor(Color.parseColor(accountInfo.getColor())); }});Copy the code
See also: github.com/stfnt/Cross…