Events
Tether dispatches standard Laravel events around offline sync, push, pull, skipped runs, and conflict handling. Register listeners in your application where you normally handle Laravel events.
Lifecycle events
| Started event | Completed event | Fired by |
|---|---|---|
TetherSyncStarted | TetherSyncCompleted | TetherClient::sync() |
TetherPushStarted | TetherPushCompleted | TetherClient::push() / PushJob |
TetherPullStarted | TetherPullCompleted | TetherClient::pull() / PullJob |
Completed events fire even when the cycle was skipped by the concurrency lock. Check $event->result->skipped.
Completed event payload
use Tether\Client\Events\TetherSyncCompleted;
class HandleSyncCompleted
{
public function handle(TetherSyncCompleted $event): void
{
$event->result->pushed;
$event->result->pulled;
$event->result->failed;
$event->result->conflicts;
$event->result->skipped;
}
}
The push and pull completed events also expose a SyncResult via $event->result.
Conflict event
TetherConflictDetected fires once for each mutation returned in the server's conflicts array, after the server state has been applied locally.
use Tether\Client\Events\TetherConflictDetected;
use Illuminate\Support\Facades\Log;
class LogConflict
{
public function handle(TetherConflictDetected $event): void
{
Log::warning('Tether conflict', [
'mutation_id' => $event->mutationId,
'model' => $event->model,
'entity_id' => $event->entityId,
'server_state' => $event->serverState,
]);
}
}
Properties:
| Property | Type | Meaning |
|---|---|---|
mutationId | string | Local mutation rejected as a conflict |
model | string | Short model name, for example Task |
entityId | string | Sync identity (tether_id by default) |
serverState | array | Current server-side attributes already saved |
Example: sync indicator
use Tether\Client\Events\TetherSyncStarted;
use Tether\Client\Events\TetherSyncCompleted;
class BroadcastSyncState
{
public function handle(TetherSyncStarted|TetherSyncCompleted $event): void
{
// Broadcast to your frontend via Laravel Echo, Reverb, etc.
broadcast(new SyncStateChanged($event instanceof TetherSyncStarted));
}
}
Syncing
Run Laravel Tether sync manually, from queues, or on a schedule, and understand push/pull results, conflicts, retries, and pull pagination.
Configuration
Reference every tether/client config key for Laravel offline sync, including client identity, HTTP endpoints, queue sync, batching, retries, and cursors.