Event Bus Vs HandlerManager in GWT? - events

When i working with one GWT project am using MVP pattern and HandlerManager for communicating on the application via Events. Now am implementing History Machanisam on my project.
They(GWT tearm) used Class EventBus for managing the events.
When read some blog i foud HandlerManger is used for Widgets and EventBus for other application wide communication.
But i feel both of them have same functionalities, then whats the purpose of this two implemetations, or whats the difference between them .
please help me

HandlerManager is the ancestor of the EventBus, which was extracted from (factored out of) it.
The main difference is that a HandlerManager has a source that it enforces on the events being dispatched to it, whereas EventBus can dispatch events with no source (fireEvent) or with a given dynamic source (fireEventFromSource). You can then attach handlers to the EventBus that will only be triggered for events from a given source.
Within widgets, you want to enforce that the event source is the widget. For a global application-wide event bus, you either want no source, or a source dynamically set for each event, as needed (RequestFactory uses it for its EntityProxyChange events so you can listen only to events related to a given kind of EntityProxy)
Note: the javadoc for HandlerManager discourages using it for an application-wide event bus.

Related

Capturing and reacting to custom windows events in wxPython

I'm in the process of writing an app to interface with a service running on another machine. When I ask this service for some information, this service adds the requested information to a separate queue, and sends a windows message to the calling application (my application) indicating there is a message waiting in this separate queue which needs to be decoded.
The windows message this service sends is a custom message, defined in the service code as having some constant int value. I've found examples of creating custom events in wxpython, and using TryBefore() and TryAfter() to react to these events in specific ways, but I haven't found any way to associate this NewEvent() with an int value so I can identify it when it comes in, much less any way to determine what an int value of an incoming event is.
Has anyone done this before or know of any functions I'm not aware of? I'm using python 3.6 and wxpython 4.0.
Thanks for your help, everyone.
I think this is what you are looking for: https://wiki.wxpython.org/HookingTheWndProc
When you get the custom message from the hooked WndProc you can either react to it there, or you can turn it into a wx event and send it so it can be caught by binding an event handler like normal. The wx.lib.newevent module has some helpers for creating a custom event class and an event binder. Its use is demonstrated in some of the demo samples and library modules.

Stop event propagation in Meteor

I've hooked up some basic click events using Meteor's event maps.
How do I stop the event from propagating after being handled?
Meteor's docs state that
Right now, the event handlers are wired up with jQuery, and the event
object you receive is a jQuery event object.
However, neither return false nor e.stopPropagation() seem to work.
Currently, stopPropagation works in a limited set of circumstances. For propagation to stop between two handlers, the handlers must be specified on different templates, and there has to be an intervening DOM node container between the inner and outer template. A fix is under development right now and will go into an upcoming release.
Can you post a gist of your code so I can make sure your particular case will be addresed?
As a workaround, you might try e.stopImmediatePropagation(), which is supplied by jQuery and should keep any other handlers from running.
I ran across this question while researching this myself. The documentation for Blaze Event Maps is here.
For this problem in meteor you need to consider 2 functions depending upon what you want:
stopPropagation()
Prevent the event from propagating (bubbling) up to other elements. Other event handlers matching the same element are still fired, in this and other event maps.
stopImmediatePropagation()
Prevent all additional event handlers from being run on this event, including other handlers in this event map, handlers reached by bubbling, and handlers in other event maps.
What I wanted was to stop bubbling and stop propagating to other Meteor event handlers. So event.stopImmediatePropagation() did the trick and it is not really a workaround as advised above.

Why are events defined as delegates

I have started working with ASP.NET controls and there appeared a question:
"why events in ASP controls are defined as delegates, and not as methods"?
Because an event must point to the function that it fires somehow and in C# this mechanism is achieved by delegates.
In response to the comment:
Then, why is such not a case with Java that uses only methods to fire
events?
Because Java uses the old traditional event pattern (like in C++). C# delegates are easier to use and also allow you to point to a static function rather than forcing the use of a class method.

Winsock object problem with WithEvents

I am developing a Standard EXE Project for sending mail.
I have a class module for sending email using winsock.
I have a withevents winsock variable set to the winsock control of a form.
The problem is that events are being catched in form's control event handler.
When i comment form's control event handling procedures and put a breakpoint in class module witheevents variable's event handler,i am unble to catch the events.
Please suggest a workaround.
If you really need to create a class (little c) that wraps constituent controls you create a UserControl, which can be invisible at runtime and have no UI interaction at all. Then, as the Winsock control's container, this UserControl will receive the events and you can handle them there.
I do this fairly often in order to create higher-level communication components, moving things like a message framing protocol inside. Then the container I put these UserControls onto only handles events raised when it has received complete messages for example. I've done the same thing to create an embeddable HTTP Server control, raising events back to the containing Form to process GET/POST requests with parameters and so on to provide a Web UI.
A Class (big C), Form, and UserControl are just three kinds of class (little c) you can create in VB6. "Class modules" really should have been called "UserClass" for clarity I suppose, in hindsight.

Should events fire themselves?

I'm not a solid GUI programmer, so I'm trying to understand different event architectures. I'm developing a system (in GWT, but I'm not sure that matters) where we are introducing a few custom events. In general, is it good practice to create an event and have the event fire itself onto to the event bus?
Following some articles and tutorials online, we have our controller code actually firing the events, but then each controller has to duplicate the code to fire the custom event. It seems that if you just put a fire() method on the event itself you can avoid that duplication.
What are the pros/cons of doing this?
In order to have an event fire itself, you'd need to inject the EventBus instance into the event when you create it. This means your controller (the one newing up the event) would have:
new MyEvent(m_eventBus).fire();
If you rework the code like this:
MyEvent event = new MyEvent();
m_eventBus.fireEvent(event);
then you wouldn't have to put any logic or references to services inside your Event instance, where it's not really needed. If you're using GWT, the HandlerManager class already implements an event bus for you.

Resources