Thank you Emmanuele,

It inherits fron GObject.

Em 30 de ago de 2016 10:55, "Emmanuele Bassi" <eba...@gmail.com> escreveu:

> Hi;
>
> you probably want to ask on javascript-l...@gnome.org, which is the
> mailing list for developing with JavaScript on GTK and GNOME.
>
> On 30 August 2016 at 14:41, Victor Aurélio Santos
> <victoraur.san...@gmail.com> wrote:
> > Subject is self explanatory,
> >
> > How to define and emit an event in GJS?
> >
> > I searched around and found nothing.
>
> I assume you mean "a signal", in the GObject signal sense.
>
> If your class is a pure JavaScript object then you want to import the
> signals module and call the addSignalMethods() on your class
> prototype, e.g.:
>
> ```
> const Lang = imports.lang;
> const Signals = imports.signals;
>
> const SomeClass = Lang.Class({ ... });
>
> Signals.addSignalMethods(SomeClass.prototype);
> ```
>
> If your class inherits from GObject, on the other hand, you can define
> signals directly inside the Lang.Class() definition, e.g.:
>
> ```
> const SomeOtherClass = Lang.Class({
>     Name: 'SomeOtherClass',
>     Extends: 'GObject.Object',
>     Signals: {
>         'no-arguments': { },
>         'some-arguments': { param_types: [ GObject.TYPE_INT,
> GObject.TYPE_INT ] },
>         'with-return': { param_types: [ GObject.TYPE_STRING,
> GObject.TYPE_INT ], return_type: GObject.TYPE_BOOLEAN ),
>     },
>     ...
> });
> ```
>
> In both cases, you'll be able to use the `emit()`, `connect()`, and
> `disconnect()` methods on your instance.
>
> Ciao,
>  Emmanuele.
>
> --
> https://www.bassi.io
> [@] ebassi [@gmail.com]
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to