/* Copyright 2026 Marimo. All rights reserved. */ import type { Atom } from "jotai"; import type { JotaiStore } from "./jotai"; export interface Observable { get(): T; sub(callback: (value: T) => void): () => void; } /** * Create an observable from a Jotai atom. * * This is just a simpler read-only API that hides the Jotai store. */ export function createObservable( value: Atom, store: JotaiStore, ): Observable { return { get: () => store.get(value), sub: (callback) => store.sub(value, () => callback(store.get(value))), }; }