Package io.objectbox

Class ObjectClassPublisher

java.lang.Object
io.objectbox.ObjectClassPublisher
All Implemented Interfaces:
DataPublisher<Class>, Runnable

@Internal class ObjectClassPublisher extends Object implements DataPublisher<Class>, Runnable
A DataPublisher that notifies DataObservers about changes in an entity box. Publishing is requested when a subscription is observed and then by BoxStore for each txCommitted. Publish requests are processed on a single thread, one at a time, in the order publishing was requested.
  • Field Details

  • Constructor Details

    • ObjectClassPublisher

      ObjectClassPublisher(BoxStore boxStore)
  • Method Details

    • subscribe

      public void subscribe(DataObserver<Class> observer, @Nullable Object forClass)
      Specified by:
      subscribe in interface DataPublisher<Class>
    • unsubscribe

      public void unsubscribe(DataObserver<Class> observer, @Nullable Object forClass)
      Removes the given observer from all object classes it added itself to earlier (forClass == null). This also considers weakly added observers.
      Specified by:
      unsubscribe in interface DataPublisher<Class>
    • unsubscribe

      private void unsubscribe(DataObserver<Class> observer, int entityTypeId)
    • publishSingle

      public void publishSingle(DataObserver<Class> observer, @Nullable Object forClass)
      Specified by:
      publishSingle in interface DataPublisher<Class>
    • publish

      void publish(int[] entityTypeIdsAffected)
    • queuePublishRequestAndScheduleRun

      private void queuePublishRequestAndScheduleRun(@Nullable DataObserver<Class> observer, int[] entityTypeIds)
      Non-blocking: will just enqueue the changes for a separate thread.
    • run

      public void run()
      Processes publish requests using a single thread to prevent any data generated by observers to get stale. This publisher on its own can NOT deliver stale data (the entity class types do not change). However, a DataObserver of this publisher might apply a DataTransformer which queries for data which CAN get stale if delivered out of order.
      Specified by:
      run in interface Runnable
    • handleObserverException

      private void handleObserverException(Class objectClass)