Execution Order
What happens first and what happens next, from a click to the updated screen. Once this is clear, questions like "why did the screen flash?" or "why was my second call refused?" answer themselves.
The big picture
1. Before triggering: debounce, interval, confirmation
| Order | Mechanism | Effect |
|---|---|---|
| ① | data-linker-debounce | Wait for the user to stop |
| ② | Minimum interaction interval (0.8 s by default) | A second click too soon: buttons drop it, fields keep the latest value and send it later |
| ③ | data-linker-confirm | Continue only after the user confirms |
| ④ | The form's cancelable submit event | Guards like FileDrop can stop it |
2. Queuing: one call at a time per mount point
The front end keeps a Promise queue per @linker mount point. Calls on the same mount point are sent and applied in order:
- A second request can never return first and overwrite the first one's result.
- In Stateful mode the revs line up.
- Different mount points don't wait for each other and can run in parallel.
#orders mount point: search ──▶ search ──▶ delete (in order)
#chart mount point: load ──▶ load (parallel with the above)3. Server: locks and revs (Stateful)
- The lock covers read → dispatch → write on the same instance.
- A request carrying an old rev (for example, two tabs sharing the same HTML) gets
conflict. dd()doesn't advance the rev or store state.
Stateless has no instance lock; calls to the same URL can run in parallel. Write correctness comes from DB transactions, unique constraints and idempotency.
4. Response: state first, then the pipeline
On success the order is fixed:
- Each key in
datais written to client state → subscribeddata-state-*bindings re-render synchronously. - The pipeline runs in order.
The other way round, dom.scrollTo would scroll to a screen that hasn't updated yet.
The namespace is decided at binding time, not when the response arrives, because the previous pipeline's render.fragment may already have replaced the trigger element.
5. Pipeline: in order, awaited, failures jump to catch
return $this->ok()
->call('ui.confirm', ['message' => 'Also send a notification email?']) // ① waits for the user
->then('render.fragment', [...]) // ② waits for the fragment to be inserted
->then('dom.scrollTo', ['target' => '#list']) // ③
->catch('ui.toast', ['level' => 'error', 'message' => 'Failed to update the screen'])
->always('form.focus', ['target' => '#keyword']);| Rule | Notes |
|---|---|
| Awaited in order | Each step (including Promises) finishes before the next starts |
| Starting state | Call succeeded = not failed; call failed = failed |
then | Runs only when not failed |
catch | Runs only when failed |
always | Always runs |
| A step throws or its action isn't registered | State becomes failed; all later then steps are skipped |
| Limit | 20 steps |
ui.confirm returns Promise<boolean> and the pipeline waits for it. But it only waits for the answer; cancelling does not turn the state into failed. For "stop if cancelled", put the confirmation on the trigger (data-linker-confirm), or split it into two calls.
When the call fails
return LinkerResponse::validation($errors)
->catch('state.set', ['scope' => 'wizard', 'key' => 'step', 'value' => 2]);- Shared error handling runs first (field errors are painted).
datais not written to state.- The pipeline starts as failed; only
catch/alwaysrun.
6. After renderBlade inserts
render.fragment is the most common async step in a pipeline. It counts as finished once:
innerHTML replaced
→ inline <script> in the fragment run
→ CGEvent.bind()
→ bindState() (data-state-init → other bindings read state back)
→ renderBladeAuto() (@renderAuto inside the fragment sends its own requests)
→ cg:rendered dispatched (new data-linker-call, charts and seeds bind here)So the next pipeline step (for example dom.scrollTo) sees new content that is already bound.
When the fragment fingerprint matches (unchanged), the HTML isn't replaced and scripts and bindings aren't re-run, because inline scripts aren't idempotent. cg:rendered still fires with detail.unchanged set to true. Pass fresh: true to force a full re-run.
7. Nested calls
An action can call another method on the same mount point through context.callLinker(). Since it already holds the queue it runs immediately rather than queuing behind itself and deadlocking. Nested calls across mount points are refused.
Common timing problems
| Symptom | Cause | Fix |
|---|---|---|
The second call gets conflict | Two pages share one instance, or @linker sits inside a re-rendered fragment | Move the mount point to an outer block |
| Scrolls to the old position | Your action didn't return a Promise, so the pipeline didn't wait | Return a Promise |
| A field error flashes then disappears | Responses from two triggers on one element overwrote each other | Already handled by "later cancels earlier"; make sure you don't send your own extra request |
| Old values reappear after saving | fresh re-rendered while state still held old values | state.clear first, then render.fragment(fresh) |
| A double click submits twice | — | The minimum interval and busy state already prevent it; writes should still be idempotent |