- From: Yonatan <notifications@github.com>
- Date: Mon, 24 Jan 2022 06:58:55 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1049/1020188467@github.com>
@bathos you are probably right, and it unnecessary for just textContent (or maybe just a syntactic sugar) I mentioned it as a textContent change effect only as an idea, but maybe having some reactive primitive in the DOM API could advance the ecosystem. maybe using an object as a dependency (using Proxy object behind the scenes) This is heavily inspired by Solidjs, as Ryan Carniato using Proxy objects just for that, and I thought "why no having it as part of the DOM API" ```JavaScript const state = domElement.createEffect(function (currentState) { this.textContent = `Hello ${currentState.x}`; }, { x: "Joe" }); state.x = "World"; ``` of course this could be implemented like that: ```JavaScript const state = new Proxy({ x: "Joe" }, { set: function (obj, prop, value) { obj[prop] = value; if (prop === "x") { domElement.textContent = `Hello ${value}`; } return true; } }); state.x = "World"; ``` But I think that the abstraction is needed to hide complexity, and making it more intuitive, closer to how popular reactive libraries are describing reactivity (when something changes, change the view) -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1049#issuecomment-1020188467 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1049/1020188467@github.com>
Received on Monday, 24 January 2022 14:59:07 UTC