0.9.7 • Published 11 months ago

@jaenster/events v0.9.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

EventTS

import {EventTS} from "@jaenster/events-ts";

interface Foo {
    on<S = this>(event: "bar", cb: (this: S, a: string) => any);
}

class Foo extends EventTS {
    z: string = '';
}

const foo = new Foo;

foo.on('bar', function () {
    // `this` is typed
    if (this.z.length) {
        // something
    }
})