capevace/livewire-optimistic-ui
wire:loading, wire:model, and Alpine.js integration natively, making it low-friction for existing Livewire components. The package extends Livewire’s reactivity model without requiring architectural overhauls.x-optimistic directives).composer.json constraints). Backward compatibility is likely for LTS releases, but edge-case testing may be needed for older versions.updatedProperty, dehydrated).addError).wire:loading).wire:loading) may suffice for simple cases.x-optimistic directives:
<!-- Before -->
<button wire:click="save">Save</button>
<!-- After -->
<button @click="$optimistic.saveComment(text); save(text)">Save</button>
x-optimistic for CRUD operations").^3.0 vs. ^2.0).<x-...>) and classic Blade. No template engine restrictions.alpinejs via CDN or npm).document.addEventListener('alpine:init', () => {
Alpine.plugin(optimisticUI);
});
<x-optimistic::injector>.x-optimistic, x-optimistic.edited, etc.) to relevant elements.updatedProperty) handle rollbacks gracefully.x-data debugging tools to inspect optimistic state.x-optimistic, x-optimistic.removed).$wire:ignore).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Network failure during optimistic update | UI shows "saved" state but server rejects | Package handles rollback, but custom error messages may need enhancement. |
| Concurrent edits (lost updates) | Overwritten data without warning | Implement server-side conflict detection (e.g., timestamps, ETags). |
| Alpine.js plugin misconfiguration | Directives fail silently | Validate plugin registration in layout. |
| Large dataset with optimistic renders | UI lag or memory issues | Debounce updates or limit optimistic scope (e.g., only for visible items). |
| Livewire property not updating | Stale optimistic state | Use `$wire:ignore |
How can I help you explore Laravel packages today?