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.

Emit is similar to DOM events, but works explicitly within the vdom tree and is user-triggerd. Calling vm.emit(evName, …args) on a view will trigger an event that bubbles up through the view hierarchy. When an emit listener is matched, it is invoked and the bubbling stops.

This does not seem to work well with explicitly injected views, which is the only use case where I have tried to use this api. It seemed natural to emit an event from within a view, then allow for anyone who has access to the vm instance to be able to subscribe to that event. I guess I was expecting something more like EventEmitter than DOM events.

Calling vm.config({ onemit: { event() } }) felt clunky anyway so I think I’ll add on and off to domvm.ViewModel.prototype in my app, but just wanted to spark a discussion since this was somewhat unexpected for me.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

leeoniyacommented, Aug 29, 2017

oh yeah 😃

made possible by the fact that fancy handlers are already called with this === vm

lawrence-dolcommented, Aug 29, 2017

Or, just:

el("li", {onclick: [vm.emit, "deleteItem",]}, "X");


That would be a great justification for emit, per my comment that GUI events provide the wrong abstraction and need to be mapped to the intended action.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Declaration emit can change type semantics when inlining internal ...
As shown in test.ts above, declaration emit type semantics change depending on whether an internal type is marked with export or not. In...
Read more >
Emitting Dynamic Methods and Assemblies - .NET Framework
Emit dynamic methods and assemblies using the System.Reflection.Emit namespace, which allows a compiler or tool to emit metadata and MSIL ...
Read more >
Shader semantics - Unity - Manual
When writing HLSL shader programs, input and output variables need to have their “intent” indicated via semantics. This is a standard concept in...
Read more >
Overview of built-in stages and their semantics - Documentation
Stream the values of an Iterable. Make sure the Iterable is immutable or at least not modified after being used as a source....
Read more >
Difference between sending a message and emitting it
Let's focus on emitting logs first. What is the difference between sending a message vs. emitting one? semantics · messaging.
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 Post

No results found

github_iconTop Related Hashnode Post

No results found