JSideris / DOThtml

A human-friendly way to build highly-dynamic web pages in pure JavaScript.
2 stars 4 forks source link

Proposal: move the reactive transformer to readers and writers. #183

Open JSideris opened 2 months ago

JSideris commented 2 months ago

So rather than there being a second argument in the watcher that has transform data, we could have a function for reader and writer (or something - maybe setAs and getAs) so that the same value can be displayed in different ways.

Here's an example.

let myWatcher = new dot.watch(0xAAAAAA);

dot.div(myWatcher.getAs(v=> `0x${v.toString(16)}`))
.input({type="color" value=myWatcher.getAs(v=> `#${v.toString(16)}`).setAs(v=>parseInt(v.subString(1), 16))})
JSideris commented 2 months ago

Could also be used for booleans and stuff. This idea is genius.