⇐ rdom: dennemark via github : […] the click counter on rdom github
could be made much simpler, but I guess it is only used as an example to show the inputTrigger function?
import { $compile, $inputTrigger } from 'https://esm.run/@thi.ng/rdom'; import { reactive } from 'https://esm.run/@thi.ng/rstream'; import { count, scan } from 'https://esm.run/@thi.ng/transducers'; // reactive value/stream setup const clicks = reactive(true); // button component with reactive label showing click count $compile([ "button", // $inputTrigger merely emits `true` onto the given reactive stream { onclick: $inputTrigger(clicks) }, "clicks: ", // using transducers to transform click stream into a counter clicks.transform(scan(count(-1))), ]).mount(document.body);
# Application Frame
//wiki.ralfbarkow.ch/assets/pages/snippet-template/esm.html
See