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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
30 views

Is it okay to remove events from subscription when there is no events

I wrote an application that when you press the start button it prints file paths to list view through events. When I press the start button it subscribes the Engine...
user avatar
  • 237
1 vote
1 answer
50 views

Basic Event manager implementation

I have written a very simple algorithm vizualizer where all input is coming from the mouse and I needed an event manager for that. Since I never wrote one before, I wrote a 30 min implementation to ...
user avatar
  • 57
0 votes
0 answers
29 views

A C WinAPI program for showing the color of the screen pixel pointed to by mouse cursor with clipboard support - follow up 2

Now it seems that I was able to make some progress with my program. See what I have: ...
user avatar
  • 25.3k
1 vote
1 answer
62 views

A C WinAPI program for showing the color of the screen pixel pointed to by mouse cursor with clipboard support - follow up

(See the previous question.) Now I have incorporated some suggestions by Barmak Shemirani. See what I have: ...
user avatar
  • 25.3k
4 votes
2 answers
233 views

A C WinAPI program for showing the color of the screen pixel pointed to by mouse cursor with clipboard support

(See the follow-up question.) I have this program that shows a small window and that window shows a rectangle whose color is the same as the color of the pixel under the mouse cursor. Note that it ...
user avatar
  • 25.3k
0 votes
1 answer
46 views

Updating active cards dynamically added by API

I am making a website where you can search through all the countries in the world. Once you have found a country you want more detail about you should be able to click and view a detailed page with ...
user avatar
2 votes
2 answers
61 views

Event Dispatcher for GLFW/Glad

I've tried to write an event dispatcher for a GLFW/Glad library. However I am not very used to writing efficient code (spent the majority of my life writing in C# and performance was never really the ...
user avatar
3 votes
1 answer
112 views

Javascript array from IP address

I want to make this code better. It works now but I think it can be better. I have a working sample on jsfiddle. When the page loads I have the End IP Address disable until the data is entered. Then I ...
user avatar
3 votes
2 answers
341 views

Event Dispatching System

Below you can see my implementation of a simple event dispatcher. I would like to get some feedback or improvement tips regarding the design and maybe an idea how to get rid of the static_cast. Thank ...
user avatar
  • 133
2 votes
1 answer
458 views

Generic Event class

C++ Event class From the desire of having a callback function which includes a void* userdata argument, I've made this generic event class. It is tested and working, but some desired features are ...
user avatar
1 vote
2 answers
73 views

Javascript - On mouseup check if any of the parents has/includes specific id

On my page I have a mouseup eventlistener on document. I want to be able catch if the clicked elements has a specific ...
user avatar
  • 113
1 vote
1 answer
100 views

list of games to open radar match in iframe on for drop-down controls

In general my page is slow and has several points in the code that I believe can be improved, even in relation to the structure used. Anyway, the biggest problem is: The page I'm creating is very ...
user avatar
3 votes
2 answers
89 views

Javascript (ES11) Event System implementation

So I decided to implement a basic event system in JavaScript. My goal was to support the following functions: on - allows the user to register a handler on the ...
user avatar
  • 415
3 votes
0 answers
96 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
0 votes
2 answers
115 views

is this a good way of using events?

So I'm currently trying to learn more about events using C# and the example that I just write seems a bit.. It seems a bit too much? I feel like you could accomplish the same thing with way less code. ...
user avatar
3 votes
2 answers
63 views

Limit second <select> options based on the first <select>

I want to see if there's a better way to write this code, solely in Javascript. There are two kinds of sets, the first set (C7, T7, C11, T11) have four options in the first select, and then up to two ...
user avatar
2 votes
1 answer
279 views

To-do app front-end in Vue 3

I have put together a To-do Application with the Slim framework on the back-end (API) and a Vue 3 front-end. I added a demo on my YouTube channel. In the main App.vue file I have: ...
user avatar
4 votes
2 answers
640 views

Vue.js checkout stepper

I have made this small checkout stepper with Vue (v 2.x.x): ...
user avatar
1 vote
1 answer
155 views

dispatch event listener problem after click

My code is working fine... but I want to remove below those(1) lines of code from my example code(2) (JS Code). If I remove those code then a tag is not working. (a tag do not open link or href is not ...
user avatar
  • 63
2 votes
1 answer
170 views

JavaScript copy-to-clipboard class

I am have made a small copy-to-clipboard script. I have made a method called copyToClipboard that does the following: create an input box; read the content of an ...
user avatar
4 votes
1 answer
78 views

Javascript Pub/Sub

Here is a short pice of code that suppose to work as Pub/Sub or EventDisptacher of some sort. I only do code in JS a few times a year, so hence I'm asking for your time. Right now I'm working on ...
user avatar
  • 43
4 votes
1 answer
2k views

C++ event loop and thread signaling

Use case This is an event loop and signaling system I created for a piece of software which will have multiple asynchronous server/clients/event-emitters/ui, some of those components will have their ...
user avatar
  • 160
3 votes
2 answers
3k views

C++: Event system for game engine

Since writing your own C++ game engine seems to be really popular these days (seriously just look at the amount of people presenting their WIPs on YouTube) I figured I'd try it myself. My mental model ...
user avatar
3 votes
1 answer
92 views

Carousel Using Vanilla Javascript

As a beginner project, I've start working on this carousel slider that would slide through an image and a testimonial on click. The number of images and content slides would always be the same number. ...
user avatar
  • 33
3 votes
1 answer
146 views

Submitting form jQuery checkboxlist

In my requestForm submit function I have this logic that checks three checkboxes and then displays the label with an error message. Is there better logic? I would be happy for any kind of feedback ...
user avatar
  • 113
7 votes
0 answers
542 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
9 votes
2 answers
323 views

Flex panels in CSS and JS

I was following Wes Bos JS 30-day challenge, so HTML and CSS are mostly are copy-paste, I'd like feedback on JS (mostly). Thanks. ...
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
8 votes
2 answers
470 views

Animated Calendar using HTML + CSS + JS

I'm a beginner developer and I'm building a calendar for smartphones. I'm using HTML, CSS and JS. I'm not entirely done with the project yet, however, I have the feeling that I'm making a messy code. ...
user avatar
2 votes
1 answer
256 views

Infinite Slider Conversion to Prototype

I've found the following example of an infinite slider to use on a project but as I will have multiple instances I have converted it to a prototype. The original example https://medium.com/@...
user avatar
  • 401
2 votes
1 answer
88 views

Multiple audio player - arrow keys & space

I am creating a VueJS component of an audio player. I am having some difficulties in finding the ideal way to get the arrow keys and space bar to work. I have found a solution, however I think it is ...
user avatar
  • 161
3 votes
1 answer
94 views

Creating a simple event message passing system in C# for a rudimentary 2d sprite game

I am currently experimenting a bit with C# and as a way of learning I am making a very simple 2D game (asteroids-ish). I am using the monogame framework and the general plan of attack was to have all ...
user avatar
1 vote
2 answers
84 views

Javascript to-do application for native Javascript

I did a simple to-do application for native Javascript. This is my first time, previously I used only jQuery. What recommendations would be useful? https://codepen.io/denibudeyko/pen/MWyEmox ...
user avatar
  • 121
3 votes
2 answers
1k views

C# One type to represent multiple types (including generics)

Our monolithic WinForm application is getting a face lift. One current challenge that we are restructuring how we setup events. I rolled my own event manager class to handle the subscriptions and ...
user avatar
  • 31
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
0 votes
1 answer
2k views

C# Event handler for WPF MVVM

So I've been learning about MVVM and I had a problem. I often had to start a thread to download or do some longer task in background and when it is done change some properties so the UI updates. The ...
user avatar
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
0 votes
1 answer
39 views

Cleaning up Javascript event listener that manages game-loop

As I added more features to my chess game, such as an endgame screen. I eventually ended up having a lot of duplicate code, and complex logic with lots of nested if statements in loops. The usual ...
user avatar
  • 177
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
2 votes
2 answers
336 views

jQuery form.find radio class

In my application we have four inputs radio controls and on the load the value is checked to true. When the user select another radio and then save the form I want to get the new value. I am using the ...
user avatar
  • 521
-2 votes
1 answer
157 views

How to test that an event will not be fired in xUnit? [closed]

I have two questions. Does it make sense to test that an event will not be fired? If yes, what is the best way to accomplish that using the xUnit framework? For ...
user avatar
  • 105
3 votes
1 answer
570 views

Summing CSV files row by row using Node.js events

I need to read multiple CSV files that have the same number of rows, and compute some results for each row. For simplification purposes, and in the scope of this code review, this computation would be ...
user avatar
  • 151
1 vote
1 answer
78 views

Showing form on btn click - preventDefault of submit btn, then remove listener

I've built out a section on a page that contains multiple instances (why I'm using querySelectorAll()) of this Request Brochure form. They are using Campaign ...
user avatar
  • 401
2 votes
2 answers
1k views

Publisher Subscriber Pattern Template

This is the first time that I have tried programming in such a general way using c++. I have tackled this pattern before in other languages such as ...
user avatar
3 votes
1 answer
58 views

eCommerce Mock App

This is a follow-up question to eCommerce Mockup App in JS. How do I implement the 'observe' pattern for the cart to regenerate html? So that, it will keep refresh its own. And any review on my coding ...
user avatar
3 votes
1 answer
62 views

Basic event stopPropagation() example - a better way of doing so?

I've got a very very basic demo here that uses the .stopPropagation method. I want to just make it so that clicking on the parent element only runs the function, so ...
user avatar
5 votes
2 answers
292 views

Message Broadcaster

I've written a basic event messenger broadcasting service. This is meant to allow for broadcasting events between loosely coupled areas of code where you may not have or care about a direct reference ...
user avatar
  • 146
3 votes
0 answers
780 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
1 answer
72 views

High-Level Managed Observers

I was thinking of adding a very high-level implementation of the event/observer pattern to my project. The implementation would manage adding and removing observers as "needed". You can use an almost ...
user avatar
6 votes
3 answers
784 views

C# Event Manager without allocations

I'm using my own Action-based Event Manager for a while and looking for ways to improve it. Mainly it's used in game development, where excessive garbage generation can lead to severe consequences. ...
user avatar
  • 380

1
2 3 4 5
10