Event handling is a coding pattern related to acting on messages between a source and one or more subscribers. A point listener in the source provides a way in which subscribed code can consume messages raised from the source.

learn more… | top users | synonyms

1
vote
0answers
19 views

Simple Pub-Sub Event Emitter

I have written a basic event emitter in JavaScript and I'd like some feedback on my design. I tried to make it as simple and minimalist as possible, as I'd like it to be understandable by anyone. I ...
0
votes
0answers
9 views

psql event store

Below are a couple of different files that comprise of example code for a postgres event store, where rows for one main table events are created, as well as a ...
2
votes
1answer
15 views

JavaScript idle managing structure

I am just getting into the world of javascript, coming from the world of classical inheritance. The following is a library I wrote to track when a webapp is idling and I wrote it like I write ...
1
vote
1answer
57 views

Java application processing GUI input when “Done” is clicked

Right now, I've got this really ugly loop in my code that waits for a boolean to be true before the method can return. It's triggered when "Done" is clicked. I'm ...
2
votes
0answers
56 views

C++ Event Emitter

I needed an event bus in C++ with a few features: Possibility to add/remove both functions and member methods. Ability to remove automatically those listeners that wrap member methods of expired ...
1
vote
1answer
64 views

Simple type-safe and thread-safe Rust event system

I'm creating a relatively simple type-safe and thread-safe Rust event system. It is to be used with and within an IRC library I'm making, but should work just fine for other use-cases. It needs to be ...
0
votes
2answers
33 views

delegate click event on document

I'm adding an onclick listener to the whole document then checking the source of the click. If the source of the click contains the attribute data-widget I want to ...
5
votes
0answers
72 views

Recorder for keyboard and mouse events

I'm building an event recorder. So far the code looks clean, but I feel like I'm missing something that can make this code even better. Is composition a better solution? If yes, how can I do it ...
1
vote
1answer
62 views

Focus next element on keypress

It's been a year or two since I last dabbled in jQuery and have attempted to write a simple "on key press move to the next element" script. However my first attempt has a lot a repetition. I just ...
1
vote
0answers
29 views

Event Service in c++

I'm interested in receiving some feedback regarding an Event system that I wrote. Both in style and implementation, but also in overall design and the design decisions that I made. It is intended to ...
3
votes
1answer
107 views

Event delegation without jQuery

I created event delegation like concept which is present in jQuery. AFAIK, event delegation is used to register an event for an element which is supposed to be added dynamically. So, in jQuery we do ...
0
votes
1answer
56 views

PageVisibility API, to handle page/tab visibility changes

Currently, I'm working on a project where I needed to run some code everytime the page is hidden. I searched high and low and found this question: Is there a way to detect if a browser window is not ...
0
votes
0answers
37 views

Event Delegates using IIFE or Module

I am learning jQuery/JavaScript best practices and am attempting to put them into practice. My overall goal is to have lots of small, independent .js files which contain specific functionality and ...
5
votes
2answers
253 views

Yet another event dispatcher in c++11

I've written an event dispatcher for a private project which task is to collect events from different threads and dispatch them in a single thread: ...
2
votes
1answer
77 views

Overriding the mouseout handler for an image when a button is clicked

I had posted this question in Stack Overflow and they told me it would be better served on Code Review. Is there a more effecient way of changing the mouseout state when a button is clicked? When a ...
1
vote
1answer
112 views

C++11 event system

I've implemented an events system in C++11. I've now got it pretty much as good as I can get it. It feels like I have found an optimal design pattern, and I'm using sensible variable names to ...
1
vote
2answers
52 views

Keyboard handler for moving in four directions

I'm having trouble deciding if I should leave the default: break; in the switch statement or not. It does kinda show intent, i.e. that most keys are not handled, ...
1
vote
2answers
66 views

Keyboard handler to move a shape in response to arrow keys

I finished Codeacademy and I'm looking to practice and get better at JavaScript. Is this coded correctly or should I have made a function for it somehow? The purpose of this code is to move a square ...
2
votes
2answers
68 views

Keyboard handler for selecting radio buttons

I have got my JavaScript working as seen here: https://jsfiddle.net/yLg1qs04/3/ But how do I condense/shorten it so that it's not repeating itself so often and taking up so many lines? ...
5
votes
2answers
225 views

Type-Safe Event System

I have recently started writing C# from a strong JavaScript background, and found myself wanting to do something I do all the time in JavaScript: events. Since I have a type system at my disposal, I ...
5
votes
1answer
89 views

Unit test if an event has been raised or not

Given the following event dispatcher code ...
3
votes
2answers
97 views

Raise an event (sample 1)

I'm writing tutorials for new programmers. The tutorials show programmers how to structure events. I've attached the code for one of the tutorials. Can someone take a look at my code and let me know ...
6
votes
1answer
215 views

C++14 Event System

I've created a simplified event system for C++14. The code is commented, so it shouldn't be hard to read. There's also a simple usage scenario below. It is still a work in progress and uses some ...
3
votes
2answers
130 views

Removing all delegates from an event dispatcher

Given a class which is an event dispatcher whose underlying store is a dictionary of events whose key is the event type ...
0
votes
0answers
26 views

A cross browser and backwards compatable solution to the PointerEvent, MouseEvent, & TouchEvent

I came up with this solution and I'm very happy with how it turned out. However, I would love some feedback from experienced developers as to its efficiency. I am working heavily with touch and mouse ...
2
votes
0answers
47 views

Alternative to clicklistener inside an anonymous class

For a trivial word game, I wrote the following code for the player to choose one of the two choices of words that in turn were read from a sentence. My question lies in first in the click-listener of ...
5
votes
2answers
101 views

Toggling dropdowns using jQuery, with binding and unbinding

This code is used to toggle some dropdowns. I've added the click event on the document to close the dropdown on click outside, but I'm not sure if I'm doing it the right way. I want it to be optimized ...
3
votes
0answers
30 views

Periodically monitor if record is not updated using Node, Event and setTimeOut

Here is my scenario: Every user checks in every five minutes. If some user doesn't check in after 5 minutes, I should be able to keep track of it. If some user doesn't check in N number of times, an ...
4
votes
1answer
34 views

Three identical AJAX button handlers in three views

In my Rails 4 app I have this event listener: ...
3
votes
2answers
169 views

Handling events in a multi threaded environment

I have a service that raises multiple events, some of them can be raised at the same time. I need to process those events and run a potentially long running method based on the event arguments. What I ...
0
votes
1answer
76 views

Form validation using IIFE and closure [closed]

Problem statement Write an IIFE in which we have to validate the input provided from a form using closures. The form consists of name, email, phone, address in which name, email and phone ...
4
votes
3answers
50 views

Track mouse coordinates

Problem Statement Write a JavaScript program that prints the mouse coordinates in a text area when the mouse cursor is moved over the HTML document. Expected Output Solution ...
7
votes
3answers
117 views

Downloading files from a Mozilla file server via FTP

All classes on GitHub repo This is the code for downloading files from a FTP-server running Mozilla Fileserver. FtpItem is the interface for the two classes ...
4
votes
2answers
63 views

C++ EventHandler class, invoking & arguments

This is my EventHandler class, which is extremely simple and can be used on lambdas and similar: ...
5
votes
3answers
115 views

Detect how long an HTML button is pressed

I recently had the need to detect how long a button is pressed and perform different actions based on that. I found some examples on Stack Overflow, but the ones I looked at showed how to use ...
2
votes
1answer
33 views

Handler for bidirectional unit conversion form

Building a form where values can be entered in either pounds or kilos. Script is... ...
3
votes
1answer
96 views

Animating sprite without libraries

I'm building a small game in pure JS for my own learning purposes, using sprites to model players. Before I go further, I want to try to get the animation down. The below code should produce a blank ...
2
votes
2answers
96 views

Xml messages processing networkstream [closed]

I'm currently processing xml messages with C#. It is working But I'm not confident that my code is fast enough. There are 3 possible messages I can receive. When I receive one the message an event is ...
2
votes
2answers
119 views

Using actionPerformed() to call different methods per radio button selection

My Java is very rusty and I have been unlucky finding a better way to accomplish this task. I have two different methods which get called based on which radio button is selected. Is there a cleaner ...
4
votes
2answers
87 views

Pub/Sub in JavaScript

This seems to work, but for some reason I'm not entirely sure about it. Can anyone point out any issues with this simple pub/sub library? Thank you! ...
5
votes
0answers
235 views

Implementing my own signal slot mechanism using C++11

I programmed in C# and I used the Qt framework. Both of them have their own signal slot mechanism which are really powerful. I looked at several implementations in C++ and based on what I learnt from ...
4
votes
2answers
112 views

Designing a Backspace key

I have designed a Backspace button (part of a keyboard which I am designing) in windows forms and it works perfect with no errors (the code works very good). This button deletes what is inside the ...
3
votes
2answers
91 views

Custom event handler in Javascript

In my web projects I often need a simple way to trigger callbacks defined somewhere else. Leaving jQuery finally behind me, I was missing their simple event system and tried to create my own. I'd like ...
2
votes
0answers
313 views

C++ 14 event bus implementation

The code allows you to subscribe to events and publish events via an EventBus class. Events are identified by a source and subject. Events can have a single ...
6
votes
1answer
177 views

Event dispatcher / listener

I'm working on a program that will be significantly multi-threaded. I need to respond to events between objects and threads so I've come up with the following code. ...
6
votes
2answers
242 views

Python Event Dispatcher

This code creates a singleton event dispatcher. It's called like this: ...
1
vote
1answer
50 views

Javascript event handling via switch

The application I am developing with has many input fields that interact with one another via the onchange event. When developing started, the goal was to create a framework that makes it easy to ...
4
votes
1answer
116 views

C++ EventHandler Class

I need to have some thread-safe event handler (like C#'s EventHandler), so I made one. Here is my event handler class and sample code (compiled with VS2013). Is ...
6
votes
1answer
123 views

Custom Event System in C#

I'm currently writing a game and want to encode everything that happens (GameObject has moved, hp changed, was created/destroyed, got/lost a component, ...) in Events that look like this: ...
4
votes
1answer
121 views

Angular wrapper for SignalR event aggregator

I created a little wrapper for one of my JavaScript libraries to enable Angular functionality. Are there any pitfalls I should be wary of with my code? ...