domvm.onevent
See original GitHub issuei’m thinking of adding a global domvm.onevent
hook to mini+ builds to augment the “view reactivity” story. basically it would provide a way to hook into all event handlers in the app and allow you to add a root auto-redraw or whatever.
due to it being global, this is something that can be used by apps at the top level, but should not be used by reusable/composable components.
it would default to a no-op, but can be overwritten to something like…
domvm.onevent = function(e, result, vm, node) {
rootVm.redraw();
};
result
is the return value of the bound event handler, so could be a Promise if the event resulted in eg. an async xhr/fetch request, so any redraw()
can be chained to it, as needed. not sold on the argument order yet, but seems sane enough.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
domvm | DOM ViewModel - A thin, fast, dependency-free ...
domvm is a flexible, pure-js view layer for building high performance web ... global domvm.cfg({ onevent: function(e, node, vm, data, args) { //...
Read more >domvm/README.md at master - GitHub
DOM ViewModel - A thin, fast, dependency-free vdom view layer - domvm/README.md at master · domvm/domvm. ... + global onevent + object/array diff...
Read more >domvm: Versions | Openbase
Full version history for domvm including change logs. ... defineSvgElement(); global domvm.config({onevent:...}) for autoredraw hookups; SSR speedups ...
Read more >DOM onevent handlers - Developer guides
The onevent handlers are properties on certain DOM elements to manage how that element reacts to events. Elements can be interactive (links, buttons,...
Read more >DOMVM - Event Handlers - JSFiddle - Code Playground
<script src="https://domvm.github.io/domvm/dist/nano/domvm.nano.iife.min.js"></script> ... vm.cfg({ onevent: vmHandler });.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
okay, a global
onevent
should definitely have a consistent signature; arg-testing would be a giant clusterfuck. i still want to pass through parameterized args if they’re provided, so[e, node, getVm(node)].concat(args)
looks like a winner. i’ll consider changing the parameterized event handler sig to match this in a future version,implemented in 6bcdfa423cc3c5ee8f2cf9da48cf8d0e39aa93b8 as
domvm.config({onevent: (e, node, vm, ...args) => {...}})
. demo: https://rawgit.com/leeoniya/domvm/2.x-dev/demos/global-onevent.html