This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy the function below to use in your scripts. | |
function createWidget() { | |
const widget = new ListWidget() | |
const wrap = (view, isWidget) => { | |
let wrapped | |
const wrapWith = (key, exec) => [key, (...args) => (exec(...args), wrapped)] | |
wrapped = Object.fromEntries(Object.keys(view).map(key => { | |
if (typeof view[key] === "function") { | |
if (key.startsWith("add")) return wrapWith(key, (...args) => { | |
let cb |