mirror of
				https://github.com/jaandrle/deka-dom-el
				synced 2025-11-03 22:59:16 +01:00 
			
		
		
		
	➖ no good direction
how to clean up not used in text re-rendering ⇒ needs to be more inside of `O.el`
This commit is contained in:
		@@ -81,24 +81,11 @@ function todoComponent({ textContent, value }){
 | 
				
			|||||||
		textContent(ev.target.value);
 | 
							textContent(ev.target.value);
 | 
				
			||||||
		is_editable(false);
 | 
							is_editable(false);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	const memo= initMemo(host);
 | 
					 | 
				
			||||||
	return el("li").append(
 | 
						return el("li").append(
 | 
				
			||||||
		O.el(is_editable, is=> is
 | 
							O.el(is_editable, is=> is
 | 
				
			||||||
			? memo("view", ()=> el("input", { value: textContent(), type: "text" }, onedited))
 | 
								? el("input", { value: textContent(), type: "text" }, onedited)
 | 
				
			||||||
			: memo("edit", ()=> el("span", { textContent, onclick: is_editable.bind(null, true) }))
 | 
								: el("span", { textContent, onclick: is_editable.bind(null, true) })
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
		el("button", { type: "button", value, textContent: "-" }, onclick)
 | 
							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;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user