Create a smart cache store for an Odoo model with offline-first capabilities.
Creates a smart cache store for Odoo models with offline-first capabilities and background sync.
/plugin marketplace add jamshu/jamshi-marketplace/plugin install odoo-pwa-generator@jamshi-marketplaceCreate a smart cache store for an Odoo model with offline-first capabilities.
Before starting, gather:
x_ prefix, e.g., "expense", "task")The generated cache store will include:
records - Reactive array of cached recordsisLoading - Loading state indicatorerror - Error statelastSync - Timestamp of last successful syncload() - Load from cache and trigger background synccreate(data) - Create new record with optimistic updateupdate(id, data) - Update record with optimistic updatedelete(id) - Delete record with optimistic updaterefresh() - Force refresh from OdooclearCache() - Clear all cached dataid > lastRecordIdsrc/lib/stores/{model}Cache.jssrc/contexts/{Model}Context.jsxsrc/stores/{model}Store.js/create-cache-store - Interactive modeRemind the user to:
load() method when the component mountsimport { taskCache } from '$lib/stores/taskCache';
// In +page.svelte
$effect(() => {
taskCache.load();
});
import { useTask } from './contexts/TaskContext';
const { records, create, update } = useTask();
import { useTaskStore } from '@/stores/taskStore';
const taskStore = useTaskStore();
taskStore.load();