OutboxedWrites class
Shared wrapper that funnels Supabase writes through the offline outbox so any screen/notifier can opt in without re-implementing the enqueue / call / mark-synced dance.
Usage pattern from a screen/notifier:
await outboxed.persistInsert(
table: 'review_log',
localId: log.id,
payload: log.toInsertJson(),
supabaseCall: () => supabase.logReview(log),
);
The screen builds the payload + the Supabase call closure; this
service handles outbox lifecycle and (silently) defers to the
SyncWorker when the live call fails. On web (no native outbox), it
falls through to a direct supabaseCall and surfaces errors to the
caller as before.
The chat notifier's _persistMessage / _persistSession helpers
predate this service and could be refactored to use it; left as-is
for now to keep this commit's diff focused on the new write paths
(review_log, user_notes, learning_objectives).
Constructors
- OutboxedWrites(OfflineOutbox? _outbox)
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
persistDelete(
{required String table, required String localId, required Map< String, dynamic> payload, required Future<void> supabaseCall()}) → Future<void> -
Enqueue a
deleteevent and attempt the live Supabase call. The payload only needs the row's primary key — replay handlers will look up additional context from the queued JSON if they need it. -
persistInsert(
{required String table, required String localId, required Map< String, dynamic> payload, required Future<void> supabaseCall()}) → Future<void> -
Enqueue an
insertevent and then attempt the live Supabase call. Failures of the live call are swallowed — the row stayspendingin the outbox and SyncWorker retries on the next online tick. Errors during enqueue (or on web with no outbox) propagate. -
persistUpdate(
{required String table, required String localId, required Map< String, dynamic> payload, required Future<void> supabaseCall()}) → Future<void> -
Enqueue an
updateevent and attempt the live Supabase call. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited