@@ -0,0 +1,1679 @@
+package org.lagonette.app.app.viewmodel;%0A%0Aimport android.arch.lifecycle.LifecycleOwner;%0Aimport android.arch.lifecycle.Observer;%0Aimport android.arch.lifecycle.ViewModel;%0Aimport android.support.annotation.NonNull;%0Aimport android.support.annotation.Nullable;%0Aimport android.support.v4.util.ArrayMap;%0A%0Aimport org.lagonette.app.app.arch.MutableLiveEvent;%0A%0Apublic class LiveEventBus extends ViewModel %7B%0A%0A    public static class Event%3CPayload%3E %7B%7D%0A%0A    private final ArrayMap%3CEvent%3C?%3E, MutableLiveEvent%3CObject%3E%3E mLiveEvents;%0A%0A    public LiveEventBus() %7B%0A        mLiveEvents = new ArrayMap%3C%3E();%0A    %7D%0A%0A    private %3CT%3E MutableLiveEvent%3CObject%3E get(@NonNull Event%3CT%3E event) %7B%0A        if (!mLiveEvents.containsKey(event)) %7B%0A            MutableLiveEvent%3CObject%3E liveEvent = new MutableLiveEvent%3C%3E();%0A            mLiveEvents.put(event, liveEvent);%0A            return liveEvent;%0A        %7D%0A        else %7B%0A            return mLiveEvents.get(event);%0A        %7D%0A    %7D%0A%0A    public %3CPayload%3E void publish(@NonNull Event%3CPayload%3E event, @Nullable Payload payload) %7B%0A        get(event).setEvent(payload);%0A    %7D%0A%0A    public %3CPayload%3E void subscribe(@NonNull Event%3CPayload%3E event, @NonNull LifecycleOwner owner, @NonNull Observer%3CPayload%3E observer) %7B%0A        //TODO What is happening when there are several observers ?%0A        get(event).observe(%0A                owner,%0A                payload -%3E observer.onChanged((Payload) payload)%0A        );%0A    %7D%0A%0A    public %3CT%3E void unregister(@NonNull Event%3CT%3E event, @NonNull LifecycleOwner owner) %7B%0A        if (mLiveEvents.containsKey(event)) %7B%0A            mLiveEvents.get(event).removeObservers(owner);%0A            mLiveEvents.remove(event);%0A        %7D%0A    %7D%0A%0A%7D%0A

Add LiveEventBus