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

Type-safe HookManager #4

Open
molenzwiebel opened this issue Nov 10, 2016 · 0 comments
Open

Type-safe HookManager #4

molenzwiebel opened this issue Nov 10, 2016 · 0 comments

Comments

@molenzwiebel
Copy link
Member

I need to take a look if TypeScript offers a convenient way to add type-safe hooks, but otherwise we will probably need overloads taking a string literal as type and delegating them to the hook, like this:

// Current code, renamed to _hook but stays unchanged.
_hook(plugin: Plugin, hookName: string, callback: Callback, ...matchers: any[]) {}

// More specific overloads per hook.
hook(plugin: Plugin, hookName: "http", callback: Callback, matcher: RegExp | string) {
    this._hook(plugin, hookName, callback, matcher);
}

// etc...
hook(plugin: Plugin, hookName: "ember-component", callback: Callback, matcher: string) {
    this._hook(plugin, hookName, callback, matcher);
}
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

1 participant