SyncEvent class

Represents a sync event for a specific action.

Use this to track the lifecycle of individual sync actions in your UI.

Example:

SyncVault.instance.onEvent.listen((event) {
  if (event.id == myJobId && event.status == SyncEventStatus.success) {
    showSnackBar('Job uploaded successfully!');
  }
});

Constructors

SyncEvent({required String id, required SyncEventStatus status, dynamic response, int? statusCode, String? error, String? idempotencyKey, required DateTime timestamp, int retryCount = 0})
const
SyncEvent.deadLetter({required String id, required String error, String? idempotencyKey, int retryCount = 0})
Creates a "dead letter" event (permanently failed).
factory
SyncEvent.failed({required String id, required String error, int? statusCode, String? idempotencyKey, int retryCount = 0})
Creates a "failed" event (will retry).
factory
SyncEvent.queued({required String id, String? idempotencyKey})
Creates a "queued" event.
factory
SyncEvent.started({required String id, String? idempotencyKey, int retryCount = 0})
Creates a "started" event.
factory
SyncEvent.success({required String id, dynamic response, int? statusCode, String? idempotencyKey})
Creates a "success" event.
factory

Properties

error String?
Error message (only available when status is SyncEventStatus.failed or SyncEventStatus.deadLetter).
final
hashCode int
The hash code for this object.
no setterinherited
id String
The unique ID of the SyncAction this event relates to.
final
idempotencyKey String?
The idempotency key if one was provided.
final
isFailure bool
Whether this event represents any kind of failure.
no setter
isPermanentFailure bool
Whether this event represents a permanent failure.
no setter
isSuccess bool
Whether this event represents a successful completion.
no setter
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
response → dynamic
The server response data (only available when status is SyncEventStatus.success).
final
retryCount int
Retry count at the time of this event.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status SyncEventStatus
The current status of the action.
final
statusCode int?
The HTTP status code (available for success and some failures).
final
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited
timestamp DateTime
Timestamp when this event was created.
final

Methods

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

Operators

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