/// /** * Favorites Manager pattern. * Referenced in: docs/common/FAVORITES.md * * @reviewed 2025-12-10 docs-rationalization */ import { Cell, handler, NAME, pattern, UI, wish } from "commontools"; type Favorite = { cell: Cell<{ [NAME]?: string }>; tag: string; userTags: Cell; }; const onRemoveFavorite = handler< Record, { favorites: Cell>; item: Cell } >((_, { favorites, item }) => { favorites.set([ ...favorites.get().filter((f: Favorite) => !f.cell.equals(item)), ]); }); const onUpdateUserTags = handler< { detail: { tags: string[] } }, { userTags: Cell } >(({ detail }, { userTags }) => { userTags.set(detail?.tags ?? []); }); export default pattern>((_) => { const wishResult = wish>({ query: "#favorites" }); return { [NAME]: "Favorites Manager", [UI]: ( {wishResult.result.map((item) => ( Remove ))} ), }; });