Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Node's EventEmitter semantics #5

Closed
romgrk opened this issue Apr 2, 2016 · 4 comments
Closed

Use Node's EventEmitter semantics #5

romgrk opened this issue Apr 2, 2016 · 4 comments

Comments

@romgrk
Copy link
Owner

romgrk commented Apr 2, 2016

Bindings should integrate smoothly with target language, therefore:

EventEmitter#on <--> GObject#connect

Maybe even inherit from EventEmitter?

@romgrk
Copy link
Owner Author

romgrk commented Jun 12, 2018

GObject#on and GObject#off implemented in 90a390d. Both are implemented in javascript, using the native connect and disconnect behavior (which return signal's handle_id).

  • Pass tests/object__events.js (.off is currently not working)
  • Add documentation

@romgrk romgrk added the 1.0 label Jun 14, 2018
@romgrk
Copy link
Owner Author

romgrk commented Jun 15, 2018

e060cc5

@romgrk romgrk closed this as completed Jun 15, 2018
@benwaffle
Copy link
Contributor

Should every GObject be an EventEmitter?

@romgrk
Copy link
Owner Author

romgrk commented Jun 15, 2018

Well the GObject framework is made so that every instance has event-listening capabilities, and it's recommended that GIR bindings integrate idiomatically with the language that's being binded, so it makes sense to have the same semantics as EventEmitter (on, off, and once).
However, those need to be implemented in terms of the native g_signal_connect_closure/g_signal_handler_disconnect (binded to .connect()/.disconnect()), so it's not really possible to just extend the EventEmitter class, unless we do something like this:

EventEmitter -> DerivedEventEmitter (implementing custom on/off/...) -> GObject

And it would also require getting an instance of the javascript EventEmitter's FunctionTemplate in C++ , which I'm not sure exactly how to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants