Class User.NotificationListener

java.lang.Object
com.syzygy.events.database.User.NotificationListener
All Implemented Interfaces:
com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>, Database.Dissolvable
Enclosing class:
User

@Dissolves public class User.NotificationListener extends Object implements Database.Dissolvable, com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>
Listeners for the creation of new notifications where the receiver is this user
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
     
    private final Consumer<Notification>
    The consumer for new notifications
    private final com.google.firebase.firestore.ListenerRegistration
    The registration of the query listener
  • Constructor Summary

    Constructors
    Constructor
    Description
    Adds a listener to the database which listens for any new notifications for this users
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the listener
    void
    onEvent(com.google.firebase.firestore.QuerySnapshot value, com.google.firebase.firestore.FirebaseFirestoreException error)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • reg

      private final com.google.firebase.firestore.ListenerRegistration reg
      The registration of the query listener
    • onNotification

      private final Consumer<Notification> onNotification
      The consumer for new notifications
    • init

      private boolean init
  • Constructor Details

    • NotificationListener

      @MustStir public NotificationListener(@Observes Consumer<Notification> onNewNotification)
      Adds a listener to the database which listens for any new notifications for this users

      Calls the `onNewNotification` consumer whenever a new notification is added to the database with the receiver being this user

      Parameters:
      onNewNotification - The consumer for new notifications
  • Method Details

    • dissolve

      public void dissolve()
      Removes the listener
      Specified by:
      dissolve in interface Database.Dissolvable
    • onEvent

      public void onEvent(@Nullable com.google.firebase.firestore.QuerySnapshot value, @Nullable com.google.firebase.firestore.FirebaseFirestoreException error)
      Specified by:
      onEvent in interface com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>