From 277ad6a7f578ea38b114a34d21b56044acb50179 Mon Sep 17 00:00:00 2001 From: Jan Andrle Date: Sun, 14 Jan 2024 09:55:23 +0100 Subject: [PATCH] :heavy_minus_sign: no good direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit how to clean up not used in text re-rendering ⇒ needs to be more inside of `O.el` --- examples/components/todosComponent.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/examples/components/todosComponent.js b/examples/components/todosComponent.js index 4337c98..da6d768 100644 --- a/examples/components/todosComponent.js +++ b/examples/components/todosComponent.js @@ -81,24 +81,11 @@ function todoComponent({ textContent, value }){ textContent(ev.target.value); is_editable(false); }); - const memo= initMemo(host); return el("li").append( O.el(is_editable, is=> is - ? memo("view", ()=> el("input", { value: textContent(), type: "text" }, onedited)) - : memo("edit", ()=> el("span", { textContent, onclick: is_editable.bind(null, true) })) + ? el("input", { value: textContent(), type: "text" }, onedited) + : el("span", { textContent, onclick: is_editable.bind(null, true) }) ), el("button", { type: "button", value, textContent: "-" }, onclick) ); } -function initMemo(host){ - const memos= new Map(); - host(on.disconnected(()=> memos.clear())); - return function useMemo(key, fn){ - let memo= memos.get(key); - if(!memo){ - memo= fn(); - memos.set(key, memo); - } - return memo; - } -}