← Electron és Vue alapok csapata adatlapja
Nézd meg, miben segít
Megbízható Vue-űrlapok és adatbetöltés
Kiszámíthatóvá teszi a Vue-űrlapokat lassú hálózat, egymást átfedő kérések és sikertelen mentés esetén is.
vue-async-forms
Ezt a skillt használó csapattagok
Mikor hasznos?
Akkor használd, ha gyors gépelés, szűrőváltás vagy ismételt kattintás miatt rossz adat jelenik meg, vagy elveszik a kitöltés.
Miben segít neked?
- Kiszűri az elavult válaszokat, és külön kezeli a betöltést, frissítést, üres eredményt és hibát.
- Védi az ismételt beküldést, sikertelen módosításnál helyreállítja az előző állapotot.
- Megőrzi a változó űrlapsorokat, és a megfelelő mezőhöz kapcsolja a szerver hibajelzését.
Például ezt kérheted
Készíts többlépéses rendelésűrlapot szerkeszthető tételekkel. Sikertelen mentés után maradjanak meg az adatok, nyíljon meg a hibás lépés, és lassú hálózaton se legyen dupla beküldés. Lassú válasz után a második lépés egyik tétele legyen hibás. A többi sor és azonosító maradjon meg, a fókusz a javítandó mezőre térjen.
Részletes dokumentáció
Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.
Összecsukás
Async UI & Complex Forms
Make every asynchronous operation and form workflow resilient to slow networks, rapid user input, out-of-order responses, interruptions and server errors.
1. Preventing stale responses and race conditions
- Whenever a user can trigger overlapping requests (typing in search boxes, switching tabs/filters rapidly, changing route params, clicking pagination), prevent an older slow response from overwriting a newer result:
- Pass an
AbortControllersignal tofetch/axiosand callcontroller.abort()insideonWatcherCleanup(Vue 3.5+) orwatch'sonCleanup((_, __, onCleanup) => onCleanup(() => controller.abort())), and on unmount. - Or increment a local
requestIdcounter before each request and ignore any response wherecurrentId !== requestIdbefore mutating reactive state (data,error,isLoading).
- Pass an
- Ignore
AbortErrorwhen setting user-facing error state so canceled requests never flash an error banner.
2. Explicit async UI states
- Model async status explicitly (
idle,loading,error,success) rather than ambiguous booleans that allow contradictory states (such as showing both an error banner and a loading spinner or a flash of "No items found" before the first request starts). - Distinguish initial load (skeleton matching the layout) from background refresh / filter update (keep existing data visible with
aria-busy="true"or a subtle progress indicator instead of blanking the screen). - On error, preserve the user's input, explain what failed clearly, and offer a working retry or recovery action.
3. Double-submit protection, retries and optimistic UI
- Guard every mutation action against double clicks or repeated
Enterpresses:- Check
if (isSubmitting.value) returnat the start of the handler, setisSubmitting.value = trueintry, and reset infinally. - Disable or mark the submit control busy while in flight.
- Check
- For optimistic updates (toggles, reordering, quick deletes), snapshot the previous state before applying the optimistic mutation, roll back to the snapshot if the request fails, and show a clear error toast.
4. Complex, dynamic and multi-step forms
- Give dynamic form array rows (line items,repeater fields) a stable unique
idgenerated at row creation (crypto.randomUUID()or counter) for:key— never:key="index", which corrupts field state and validation errors when rows are inserted or removed. - Separate field-level validation timing: validate eagerly only after a field has been blurred (
touched) or after the first submit attempt, and clear a field's error as soon as the user corrects it. - Map server-side field validation errors (
422) back onto the corresponding fields, open the step/tab containing the first invalid field in multi-step forms, and move focus to the first invalid input (aria-invalid="true",aria-describedby). - Track dirty state against the initial snapshot so
Cancel, modal close or route leave warns before losing unsaved work.
Before you finish
- Rapid filter/tab/param changes cancel or ignore stale responses via
AbortControlleror request tokens. - Mutations block duplicate submissions while in flight and preserve user input when a request fails.
- Dynamic form rows use stable unique keys, and server/client validation errors link to fields and focus the first invalid control.
- Loading, empty, error, retry and dirty-leave states all work predictably.
Csomagban lévő fájlok 2
LICENSE.txtSKILL.md
