Questions tagged [event-handling]

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.

60 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
0 answers
500 views

Simple, intuitive and (hopefully) safe EventDispatcher

For my own game engine I need an event system. I tried to avoid the single-huge-enum-approach for minimizing compile times. The BasicEventListener is the (...
user avatar
7 votes
0 answers
606 views

C++ Event System - Game Engine

Introduction I have just started learning templates and experimenting with function pointers. I wanted to create an event system that met a couple of goals: Event types are PODs, and do not inherit ...
user avatar
  • 281
5 votes
0 answers
2k views

C++ game engine event system implementation

I am currently working on the implementation of Event System on a game engine. I have zero experience in Event System implementation or the patterns that are used. What I have done is what I've seen ...
user avatar
5 votes
0 answers
74 views

FRP: Processing task lists

I recently heard about functional reactive programming and thought it was rather interesting. Therefore, I started out with writing a simple program which processes a list of tasks. (In this example, ...
user avatar
5 votes
0 answers
2k views

Reducing complexity in NSView event handling code in Swift

My Cocoa event code always tends to descend into madness, I need to advice on how to reduce complexity. I've spend a few hours putting this example together. CanvasView is a layer hosting subclass of ...
user avatar
4 votes
0 answers
1k views

Mouse wheel scrolling for nested scrollable Swing components

By default, mouse wheel scrolling in Java Swing behaves differently than in web browsers. In Swing, when you have an inner scrollable component and an outer scrollable component, the mouse wheel ...
user avatar
  • 20.9k
4 votes
0 answers
87 views

"Lock-free" one-shot event manager

Giving a review to Oachkatzl and recently about some other synchronization problems (Lazy with invalidate and some node-locking list), I wanted to test my skills and redesign it in most light-weight ...
user avatar
4 votes
0 answers
387 views

Media player subtitles in WPF - Part 2 Handlers and notifications

This is a continuation of Part 1. In this question I will present you with a single class which is the most crucial component of the whole system, it's responsible for firing notifications whenever a ...
user avatar
  • 8,418
4 votes
0 answers
75 views

Comparison of sprite movement implementations

I've come up with two ways to do sprite movement with CreateJS, and I'm wondering if one is better than the other as far as performance and maintainability. The player data is saved in a json file ...
user avatar
4 votes
0 answers
1k views

Anonymous Events in Delphi

I wrote a anonymous event creator. I would like to ask if anyone can tell me if I did it the "right" or "best" way, or how I could make it better. Here is what I did: Declaration: ...
user avatar
  • 315
3 votes
0 answers
99 views

A Compile-time templated event system and dispatch manager

Problem I would like to make an efficient, extensible, and potentially asynchronous parallelizable event system using modern features in C++20. My solution I've constructed a templated event struct by ...
user avatar
  • 131
3 votes
0 answers
829 views

Simple event broker / eventbus in C# (~100 lines of code)

Background I was looking for a simple Event Broker or EventBus (whatever else keyword you can come up with) to use in a small(-...
user avatar
3 votes
0 answers
64 views

Javascript Call To Action Modal

I created a simple modal that when a user scrolls down a blog post, a modal pops up. If the user wants to sign up for newsletter, then a form pops up. The only external library I used was body-scroll-...
user avatar
  • 267
3 votes
0 answers
303 views

C++ Generic Action Dispatching & Handling System

I am trying to achieve an event system, which I refer as actions, and would like your ideas about what I come up with so far. I have made research on several design patterns, and several systems used ...
user avatar
3 votes
0 answers
409 views

Media player in WPF - Event binding

I recently started making a media player, this is the first time I'm using WPF and I found that most project are utilizing the MVVM architectural pattern, I haven't used that one either but I decided ...
user avatar
  • 8,418
3 votes
0 answers
69 views

Creating an observable stream of clicks and converting it to an iterator

Problem 1 StratifiedJS allows people to cleanly create observable streams using the Stream class from sjs:sequence: ...
user avatar
  • 131
3 votes
0 answers
156 views

Adding swipe support to multiple classes

I have implemented swipe functionality using UIPanGestureRecognizer in a project. What I have done is added PanGesture to ...
user avatar
3 votes
0 answers
45 views

Simple gallery with scroll

I just created a simple gallery with scroll. Everything works fine but I'm not sure how should I optimize this code: ...
user avatar
3 votes
0 answers
765 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 ...
user avatar
  • 131
3 votes
0 answers
41 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 ...
user avatar
  • 131
3 votes
0 answers
122 views

Encapsulating behavior spread across multiple event handlers

I wrote a chatbot in Ruby for turntable.fm, a chatroom where users can listen to music together. It interacts with users in a room, who can type in specific keywords and get responses from it. It also ...
user avatar
  • 133
2 votes
0 answers
630 views

JavaScript: implement event listener in custom object

For many years, there have been several JavaScript libraries for implementing custom events and event listeners. But, as MDN web docs suggests, there are now available constructable Event, CustomEvent ...
user avatar
  • 121
2 votes
0 answers
466 views

Angular 8: Scroll spy implementation for a timeline Contents

I have made a timeline component that can have multiple milestone/major/minor as sub components nested within timeline container component. I have also added a side navigation for that lists all ...
user avatar
2 votes
0 answers
4k views

Event management system in C++

I have this question asked as home assignment for an interview. I submitted my solution and did not get selected. Wanted to know your feedback for the solution. Question: Write a very simple ...
user avatar
  • 21
2 votes
0 answers
24 views

UI Event Flow class

Purpose: I wanted a way to improve event clarity and event code organization. I observed that every single event flow went through the following steps: Trigger -> UI Change -> (Async) ...
user avatar
  • 1,960
2 votes
0 answers
137 views

Observer(Event) system (Signals and Slots), type and template based

Signals are represented as types. You can connect a member function of some instance to the Observer system. This connected function will be called whenever a signal of a type that is the same type as ...
user avatar
2 votes
0 answers
1k views

PyQt frame which changes color with child focus

I am working on an application that has various "panels" contained within splitters. I wanted the panel border to change color when one of it's children gained focus. Here is a simple example of the ...
user avatar
  • 261
2 votes
0 answers
253 views

Search GitHub users when text field changes in Kotlin Android app

Problem: Search for users by their name using the GitHub API (sorted by the number of followers) and display the results in a RecyclerView. Implementation: Hitting the GitHub API every time when user ...
user avatar
  • 121
2 votes
0 answers
47 views

Event handler re-use in Javascript

I've been trying to deal with a lot of duplicate code in the first web pages I've been working on and have been playing around with the prototype model, which I think is the 'right' way to go about it....
user avatar
2 votes
0 answers
26 views

Event based read and output file lines

In the near future, the app will have to start several actions after having read the content of the file (executing request based on the request module). I was ...
user avatar
  • 121
2 votes
0 answers
60 views

Two similar methods to re-create objects and emit events

I have these two methods basically doing the same thing: ...
user avatar
2 votes
0 answers
2k views

Simple event handling system

I have written a simple event handling system, which is intended for a game but right now I am just trying to get a general framework created. This is simply for practice for myself, but I am trying ...
user avatar
  • 21
2 votes
0 answers
54 views

Custom event trigger and listener module

I am working on a data collection JavaScript library, and would like other members of my organization to be able to write loosely coupled plugins to extend its core functionality. I've been working on ...
user avatar
  • 141
2 votes
0 answers
236 views

Generating a carousel slider

I'm currently using Backbone to generate a carousel slider. In my View, I have an initialize function that looks like this: <...
user avatar
  • 121
2 votes
0 answers
449 views

Swing keybinding to control an animated car

In my textbook there is no mention of keybindings and it encourages the use of keylistener so there isn't any example code using keybindings for its problems. I was wondering if this is sorta close to ...
user avatar
  • 147
2 votes
0 answers
370 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 ...
user avatar
  • 201
2 votes
0 answers
226 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 ...
user avatar
2 votes
0 answers
63 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 ...
user avatar
2 votes
0 answers
3k 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 ...
user avatar
  • 140
2 votes
0 answers
293 views

handle drag and drop operations

I've come up with the following code to handle drag and drop operation. It's composed of a constructor function that returns an objects with methods to attach to event handlers. Notes about this ...
user avatar
1 vote
0 answers
51 views

Basic Event Cancellation

I recently came across the need to allow consumers to prevent further execution of methods and I utilized an event driven system that allows the consumer to specify if the execution should cancel. I'...
user avatar
1 vote
0 answers
23 views

Dynamic adding and removing div elements using event streams (eventlistners)

I has div block feedList which contains feedItems. Now to fill ...
user avatar
  • 186
1 vote
0 answers
90 views

How to refactor below nodejs code to unblock event-loop?

I produced below code and soon it became outdated due to the blocking nature of it's loops which I can't see how to avoid that. Work-flow summery Client send a request to "/" to get a list of JS ...
user avatar
  • 119
1 vote
0 answers
52 views

AIPlaylist: Adaptive media player using VLCJ and Swing

I created a project using VLCJ and a probability function to create a media player that plays your favorite media more often than the others, because I wanted to hear my favorite music and videos more ...
user avatar
1 vote
0 answers
53 views

Repetitive code for an event listener

So I'm using the event emitter as some sort of an event bus(If I'm allowed to call it that). The problem I've stumbled upon is that my listeners might want different data than another listener. Since ...
user avatar
  • 153
1 vote
0 answers
20 views

Creating a reusable plugin (Dialog/Notifier as example)

I started working on a notification system that is pluggable into any project. I have not made any "plugin" type javascript libraries, usually just functions very specific to the project at hand. That ...
user avatar
  • 704
1 vote
0 answers
41 views

Dragging and dropping a spot using TypeScript

Currently my code is based around mouse events so that it is easier to test but I will be swapping these to touch events once I have had the code reviewed. The idea of the UX is that you need to ...
user avatar
  • 219
1 vote
0 answers
88 views

ReactJS code that allows at most one profile pic to be selected

I am making a profile picture selection screen, basically you select a picture pic1, if another picture pic2 is selected, then we cancel the highlight of pic2 and highlight pic1. Here is my code right ...
user avatar
  • 111
1 vote
0 answers
183 views

Golang message bus for a game engine

I wrote a memory bus struct in golang to allow systems to interact with each other without knowing anything about the receiver. This is for a game engine. I know it's not good to write games in ...
user avatar
1 vote
0 answers
81 views

Modeling the Aggregates in the following Bounded Context - Domain Driven Design

I'm currently developing an application in ASP.NET Core 2.2 with Domain Driven Design. What you see in here is a Unit Creation page. A Unit is composed of competences. A unit must have at least one ...
user avatar
  • 213