Move ModelProvider and ModelFeature and ModelToken to use Observable interface

PiperOrigin-RevId: 250767535
Change-Id: I2f47565cdba70485fff4eb4b082b1bd99f664dd1
diff --git a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/BUILD b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/BUILD
index 120eb57..595bf1c 100644
--- a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/BUILD
+++ b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/BUILD
@@ -8,6 +8,7 @@
     deps = [
         "//src/main/java/com/google/android/libraries/feed/api/common",
         "//src/main/java/com/google/android/libraries/feed/api/host/logging",
+        "//src/main/java/com/google/android/libraries/feed/common/feedobservable",
         "//src/main/java/com/google/android/libraries/feed/common/functional",
         "//src/main/proto/com/google/android/libraries/feed/api/internal/proto:client_feed_java_proto_lite",
         "//src/main/proto/search/now/wire/feed:feed_java_proto_lite",
diff --git a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelFeature.java b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelFeature.java
index 7dc5b98..3b15b0d 100644
--- a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelFeature.java
+++ b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelFeature.java
@@ -14,6 +14,7 @@
 
 package com.google.android.libraries.feed.api.internal.modelprovider;
 
+import com.google.android.libraries.feed.common.feedobservable.Observable;
 import com.google.search.now.feed.client.StreamDataProto.StreamFeature;
 
 /**
@@ -21,7 +22,7 @@
  * a Cluster, Carousel, Piet Content, etc. Features provide an {@link ModelCursor} for accessing the
  * children of the feature.
  */
-public interface ModelFeature {
+public interface ModelFeature extends Observable<FeatureChangeObserver> {
 
   /**
    * Returns the {@link StreamFeature} proto instance allowing for access of the metadata and
@@ -45,13 +46,4 @@
    */
   /*@Nullable*/
   ModelCursor getDirectionalCursor(boolean forward, /*@Nullable*/ String startingChild);
-
-  /**
-   * Register a {@link FeatureChangeObserver} for changes on this feature. The types of changes
-   * would include adding or removing children or updates to the payload.
-   */
-  void registerObserver(FeatureChangeObserver observer);
-
-  /** Remove a registered observer */
-  void unregisterObserver(FeatureChangeObserver observer);
 }
diff --git a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelProvider.java b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelProvider.java
index 9e85f4f..8b79350 100644
--- a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelProvider.java
+++ b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelProvider.java
@@ -17,6 +17,7 @@
 import android.support.annotation.IntDef;
 import com.google.android.libraries.feed.api.common.MutationContext;
 import com.google.android.libraries.feed.api.host.logging.RequestReason;
+import com.google.android.libraries.feed.common.feedobservable.Observable;
 import com.google.search.now.feed.client.StreamDataProto.StreamSharedState;
 import com.google.search.now.feed.client.StreamDataProto.UiContext;
 import com.google.search.now.wire.feed.ContentIdProto.ContentId;
@@ -28,7 +29,7 @@
  * relationship between the ModelProvider and Session implementation. The Stream Library uses the
  * model to build the UI displayed to the user.
  */
-public interface ModelProvider {
+public interface ModelProvider extends Observable<ModelProviderObserver> {
   /**
    * Provides the contentId of the lowest child of the root viewed by the user, or {@code null} if
    * no content with a ContentId has been seen.
@@ -155,13 +156,4 @@
 
   /** Called by the stream to set the {@link RemoveTrackingFactory}. */
   void enableRemoveTracking(RemoveTrackingFactory<?> removeTrackingFactory);
-
-  /**
-   * Register a {@link ModelProviderObserver} for changes on this container. The types of changes
-   * would include adding or removing children or updates to the metadata payload.
-   */
-  void registerObserver(ModelProviderObserver observer);
-
-  /** Remove a registered observer */
-  void unregisterObserver(ModelProviderObserver observer);
 }
diff --git a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelToken.java b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelToken.java
index a00c557..550be80 100644
--- a/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelToken.java
+++ b/src/main/java/com/google/android/libraries/feed/api/internal/modelprovider/ModelToken.java
@@ -14,19 +14,14 @@
 
 package com.google.android.libraries.feed.api.internal.modelprovider;
 
+import com.google.android.libraries.feed.common.feedobservable.Observable;
 import com.google.search.now.feed.client.StreamDataProto.StreamToken;
 
 /** Defines the behavior of a Continuation Token. */
-public interface ModelToken {
+public interface ModelToken extends Observable<TokenCompletedObserver> {
   /** Returns the {@link StreamToken} proto instance. */
   StreamToken getStreamToken();
 
   /** Returns {@code true} if token was generated on-device and can complete quickly. */
   boolean isSynthetic();
-
-  /** Register a {@link TokenCompletedObserver} for completion of this continuation token. */
-  void registerObserver(TokenCompletedObserver observer);
-
-  /** Remove a registered observer */
-  void unregisterObserver(TokenCompletedObserver observer);
 }