PrioritizedCallback<T extends Function> class

Callback with priority for ordered execution.

Higher priority callbacks execute first (e.g., priority 100 runs before priority 0). Callbacks with the same priority execute in parallel via Future.wait. Different priorities execute sequentially (all callbacks at priority N complete before priority N-1 starts).

Default Priorities

Service Callback Priority Rationale
DeviceService onAuthenticated 0 Default
DeviceService onAboutToLogOut 0 Default
NotificationService onAuthenticated 0 Default, runs parallel with DeviceService
NotificationService onAboutToLogOut 0 Default, defers to DeviceService when present

Custom Priorities

  • Positive priorities (e.g., 100) to run before default services
  • Negative priorities (e.g., -100) to run after default services

Example

final auth = AuthServiceImpl(
  firebaseApp: app,
  onAuthenticatedCallbacks: [
    PrioritizedCallback(deviceService.handleAuthenticated, priority: 0),
    PrioritizedCallback(notificationService.handleAuthenticated, priority: 0),
    PrioritizedCallback(analyticsService.onLogin, priority: -10), // After core services
  ],
);

Constructors

PrioritizedCallback(T callback, {int priority = 0})
Creates a prioritized callback.
const

Properties

callback → T
The callback function to execute.
final
hashCode int
The hash code for this object.
no setterinherited
priority int
The execution priority. Higher values execute first.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited