Coder Social home page Coder Social logo

Signal group. about wink-signals HOT 3 OPEN

Wolftein avatar Wolftein commented on September 19, 2024
Signal group.

from wink-signals.

Comments (3)

miguelmartin75 avatar miguelmartin75 commented on September 19, 2024

Could you give an example of usage? Or how this could be used for an application.

from wink-signals.

Wolftein avatar Wolftein commented on September 19, 2024

An example would be:

#define NORMAL 0
#define HIGHEST 2
#define HIGH 1

EventManager.addSignal<void (Event&>("MyEvent", &Function1, NORMAL);
EventManager.addSignal<void (Event&>("MyEvent", &Function2, HIGHEST);
EventManager.addSignal<void (Event&>("MyEvent", &Function3, HIGH);
EventManager.execute("MyEvent", &EventStructure);

Function1, Function3 and Function2 is executed in that order. The example is for a game that use delegates to make an event system.

Function1
(
setEventCancelled(canMove());
)

Funcion3
(
if( isCancelled() )
return
TriggerACustomMovementEvent()
)

Function2
(
if( !isCancelled() )
return;
updateTiles()
)

from wink-signals.

miguelmartin75 avatar miguelmartin75 commented on September 19, 2024

One thing I'd like to mention, a signal can have multiple "slots"* (a.k.a. functions) connected to it. Are you sure you're referring to a signal? All a signal really is a wrapper for a vector of slots.

Also, I don't really have time to implement any of this anytime soon (I'm quite busy with other projects ATM). Perhaps you could do it and make a fork. If you do try to keep the same naming conventions.

*std::function, and my custom slots work with signals. Just thought I'd mention it, if I didn't in the README, as I haven't updated this library in months.

from wink-signals.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.