Coder Social home page Coder Social logo

signals's People

Contributors

6j7kzg2f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

signals's Issues

Is it possible to inject signals in class ?

I'm using many callbacks ( via signals) and if I want to use singleton ( for dispatch and add in different class ) for each signal I should call at example SignalSingletonClass.get(mysignal1).add / dispatch.
Is it possible to use some kind of inject ?
At example I'm using minject at the moment setting all signals asSingleton and calling injectInto(target)
Which bring declaration of signal to something like @inject public var mySignal1:MySginal1; .... and one call of injectInto

Fails on hashlink target

I get this error when I use Signal1 class
Signal.hx:159: characters 30-38 : Don't know how to cast (dyn):void to ():void

Conflicting namespaces on OSX with hxcpp

Following on from my PR (#2) the following code sample will not compile on OSX High Sierra with hxcpp git and haxe 4.0.0-rc.2

import signal.Signal;

class Main
{
    static function main()
    {
        var signal = new Signal();
        signal.add(() -> trace('hello world!'));
        signal.dispatch();
    }
}

You get the following error log.

Error: In file included from ./src/signal/Signal.cpp:5:
include/signal/BaseSignal.h:10:19: error: redefinition of 'signal' as different kind of symbol
HX_DECLARE_CLASS1(signal,BaseSignal)
                  ^
/usr/include/sys/signal.h:390:8: note: previous definition is here
void    (*signal(int, void (*)(int)))(int);
          ^
In file included from ./src/signal/Signal.cpp:5:
include/signal/BaseSignal.h:12:11: error: redefinition of 'signal' as different kind of symbol
namespace signal{
          ^
/usr/include/sys/signal.h:390:8: note: previous definition is here
void    (*signal(int, void (*)(int)))(int);
          ^
In file included from ./src/signal/Signal.cpp:5:
include/signal/BaseSignal.h:43:29: error: no member named 'BaseSignal' in namespace 'signal'
HXLINE(  44)            ( ( ::signal::BaseSignal)(__this) )->priorityUsed = false;
                            ~~~~~~~~~~^
include/signal/BaseSignal.h:44:29: error: no member named 'BaseSignal' in namespace 'signal'
HXLINE(  43)            ( ( ::signal::BaseSignal)(__this) )->requiresSort = false;
                            ~~~~~~~~~~^
include/signal/BaseSignal.h:45:29: error: no member named 'BaseSignal' in namespace 'signal'
HXLINE(  42)            ( ( ::signal::BaseSignal)(__this) )->toTrigger = ::cpp::VirtualArray_obj::__new(0);
                            ~~~~~~~~~~^
include/signal/BaseSignal.h:46:29: error: no member named 'BaseSignal' in namespace 'signal'
HXLINE(  41)            ( ( ::signal::BaseSignal)(__this) )->callbacks = ::Array_obj< ::Dynamic>::__new(0);
                            ~~~~~~~~~~^
include/signal/BaseSignal.h:47:29: error: no member named 'BaseSignal' in namespace 'signal'
HXLINE(  40)            ( ( ::signal::BaseSignal)(__this) )->fireOnAdd = false;
                            ~~~~~~~~~~^
include/signal/BaseSignal.h:48:29: error: no member named 'BaseSignal' in namespace 'signal'
HXLINE(  48)            ( ( ::signal::BaseSignal)(__this) )->fireOnAdd = fireOnAdd;
                            ~~~~~~~~~~^
In file included from ./src/signal/Signal.cpp:8:
include/signal/Signal.h:13:19: error: redefinition of 'signal' as different kind of symbol
HX_DECLARE_CLASS1(signal,BaseSignal)
                  ^
/usr/include/sys/signal.h:390:8: note: previous definition is here
void    (*signal(int, void (*)(int)))(int);
          ^
In file included from ./src/signal/Signal.cpp:8:
include/signal/Signal.h:14:19: error: redefinition of 'signal' as different kind of symbol
HX_DECLARE_CLASS1(signal,Signal)
                  ^
/usr/include/sys/signal.h:390:8: note: previous definition is here
void    (*signal(int, void (*)(int)))(int);
          ^
In file included from ./src/signal/Signal.cpp:8:
include/signal/Signal.h:16:11: error: redefinition of 'signal' as different kind of symbol
namespace signal{
          ^
/usr/include/sys/signal.h:390:8: note: previous definition is here
void    (*signal(int, void (*)(int)))(int);
          ^
./src/signal/Signal.cpp:14:11: error: redefinition of 'signal' as different kind of symbol
namespace signal{
          ^
/usr/include/sys/signal.h:390:8: note: previous definition is here
void    (*signal(int, void (*)(int)))(int);
          ^
./src/signal/Signal.cpp:16:6: error: use of undeclared identifier 'Signal_obj'
void Signal_obj::__construct( ::Dynamic fireOnAdd){
     ^
./src/signal/Signal.cpp:21:9: error: use of undeclared identifier 'Signal_obj'
Dynamic Signal_obj::__CreateEmpty() { return new Signal_obj; }
        ^
./src/signal/Signal.cpp:23:7: error: use of undeclared identifier 'Signal_obj'
void *Signal_obj::_hx_vtable = 0;
      ^
./src/signal/Signal.cpp:25:9: error: use of undeclared identifier 'Signal_obj'
Dynamic Signal_obj::__Create(hx::DynamicArray inArgs)
        ^
./src/signal/Signal.cpp:32:6: error: use of undeclared identifier 'Signal_obj'
bool Signal_obj::_hx_isInstanceOf(int inClassId) {
     ^
./src/signal/Signal.cpp:40:6: error: use of undeclared identifier 'Signal_obj'
void Signal_obj::dispatch(){
     ^
./src/signal/Signal.cpp:81:25: error: unknown type name 'Signal_obj'
HX_DEFINE_DYNAMIC_FUNC0(Signal_obj,dispatch,(void))
                        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Failed to invoke `haxelib run-dir hxcpp /Users/aidanlee/haxe/haxe_libraries/hxcpp/4.0.0/github/978797989cccff7798b995888a5060388c4d1b76 Build.xml haxe -Dhaxe3=1 -Dhaxe4=1 -Dhaxe_ver=4.000 -Dhxcpp_api_level=400 -Dsignals=1.0.9 '-Dsource-header=Generated by Haxe 4.0.0-rc.2+77068e1' -Dstatic=1 -Dtarget.name=cpp -Dtarget.static=true -Dtarget.sys=true -Dtarget.threaded=true -Dtarget.utf16=true -Dutf16=1 -I/Users/aidanlee/haxe/haxe_libraries/signals/1.0.9/github/4026c0b6adf7e3801a026945a1004487d9c73cad/src/ -Isrc/ -I -I/Users/aidanlee/haxe/versions/4.0.0-rc.2/std/cpp/_std/ -I/Users/aidanlee/haxe/versions/4.0.0-rc.2/std/` because Error: Command failed: haxelib run-dir hxcpp /Users/aidanlee/haxe/haxe_libraries/hxcpp/4.0.0/github/978797989cccff7798b995888a5060388c4d1b76 Build.xml haxe -Dhaxe3=1 -Dhaxe4=1 -Dhaxe_ver=4.000 -Dhxcpp_api_level=400 -Dsignals=1.0.9 '-Dsource-header=Generated by Haxe 4.0.0-rc.2+77068e1' -Dstatic=1 -Dtarget.name=cpp -Dtarget.static=true -Dtarget.sys=true -Dtarget.threaded=true -Dtarget.utf16=true -Dutf16=1 -I/Users/aidanlee/haxe/haxe_libraries/signals/1.0.9/github/4026c0b6adf7e3801a026945a1004487d9c73cad/src/ -Isrc/ -I -I/Users/aidanlee/haxe/versions/4.0.0-rc.2/std/cpp/_std/ -I/Users/aidanlee/haxe/versions/4.0.0-rc.2/std/
Error: Build failed

The issue seems to be that the OSX SDK already defines the signal namespace and hxcpp converts haxe packages into cpp namespaces. The above sample will compile fine on OSX when using my fork where I renamed to haxe packages from signal to petesignals. I've had no issues with the library and hxcpp on Windows and Linux.

Cheers.

Signal2.hx:5: characters 41-42 : Unexpected ,

Hey, thanks for this nice lib!

While trying to use the Signal2 class, I get a compiler error from Haxe 3.4.7:
Signal2.hx:5: characters 41-42 : Unexpected ,

Could you give it a try?

How to manage many different signals via one class ?

At the moment I use many signals in different classes and it's a little bit hard to follow all of them.
What I tried to do is to create class SignalManager and all signals to use this class.

At example for SignalManager, I will have signalMap with :

  • key string - type of the signal
  • value - the signal .

When make add, I will do

signalManager.add("OPEN_FILE_BUTTON" , clickOnButton);

signalManager.remove("OPEN_FILE_BUTTON");

How can easy do that ?

function add is

function add(eventName:String, listener:Callback, numParams:Int = 0) {
   if ( numParams ==0) { 
      var signal = new  new Signal0();
      signal.add(listener);
     signalMap[eventName] = listener;
  } else   if ( numParams == 1) { 
      var signal = new  new Signal1()<T>;
      signal.add(listener);
     signalMap[eventName] = listener;
  } else   if ( numParams == 2) { 
     var signal = new  new Signal2()<T,T>;
      signal.add(listener);
     signalMap[eventName] = listener;
  } 
}```

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.