question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

i’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:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
leeoniyacommented, Mar 23, 2017

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,

0reactions
leeoniyacommented, Mar 23, 2017

implemented in 6bcdfa423cc3c5ee8f2cf9da48cf8d0e39aa93b8 as domvm.config({onevent: (e, node, vm, ...args) => {...}}). demo: https://rawgit.com/leeoniya/domvm/2.x-dev/demos/global-onevent.html

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found