Skip to content

Instantly share code, notes, and snippets.

View grocco's full-sized avatar
🛍️
Developing Shopify Apps

Rocco Ghielmini grocco

🛍️
Developing Shopify Apps
  • Ghielmini Informatics
  • Lugano, Switzerland
  • 22:23 (UTC +02:00)
  • LinkedIn in/roccoghielmini
View GitHub Profile
@grocco
grocco / deepStore.ts
Created October 10, 2025 10:55
Proxy-based state management for React 18+
import { useSyncExternalStore } from "react";
type Listener = () => void;
export function createStore<T extends object>(initialState: T) {
const listeners = new Set<Listener>();
let cachedSnapshot: T;
const notify = () => {
cachedSnapshot = clone(state);
@grocco
grocco / useLocalStorage.ts
Last active September 28, 2025 23:53
Vue@3 useLocalStorage composable
import { onMounted, onUnmounted, ref, watch } from 'vue';
export function useLocalStorage(key: string, defaultValue: any = null, deep = false) {
let initialValue;
try {
initialValue = JSON.parse(localStorage.getItem(key) || "null") || defaultValue
} catch (e) {
initialValue = defaultValue