SyncService class
Simple service to simplify Timer instances management across the package.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- onConnected ↔ VoidCallback?
-
Called after the WebSocket successfully connects (including reconnects).
getter/setter pair
- onDefinitionsRevisionUpdated ↔ void Function(String etag)?
-
Called when a WebSocket message carries a new definitions revision.
getter/setter pair
-
onRefreshRequested
↔ Future<
void> Function({required bool forceJwksRefresh})? -
Debounced callback when definitions should be refreshed from the API.
getter/setter pair
- onSyncMessage ↔ void Function({String? etag, required bool unchanged})?
-
Callback for WebSocket
syncmessages.getter/setter pair - refreshFeatureFlagsTimer ↔ Timer?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- wsConnected ↔ bool
-
Whether the WebSocket is currently connected.
getter/setter pair
- wsReconnecting ↔ bool
-
Whether a reconnect attempt is scheduled or in progress.
getter/setter pair
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
requestRefresh(
{bool forceJwksRefresh = false}) → void - Schedules a debounced definitions refresh.
-
startWebSocket(
{required String baseURI, required String appKey, String? cachedRevision}) → void - Starts a WebSocket connection for live feature flag updates.
-
stopWebSocket(
) → void - Stops the WebSocket connection and cancels pending timers.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCachedRevision(
String? revision) → void -
Updates the cached revision used for reconnect
?rev=query params.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- getInstance → SyncService
-
Returns the SyncService singleton instance.
no setter
Static Methods
-
reconnectDelayForAttempt(
int attempt) → Duration - Computes the next reconnect delay using exponential backoff.
Constants
- refreshDebounceDelay → const Duration
- Debounce window for refresh callbacks triggered by WebSocket messages.
- wsReconnectBaseDelay → const Duration
- Base delay before the first reconnect attempt.
- wsReconnectMaxDelay → const Duration
- Maximum delay between reconnect attempts.