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

add the KeyboardShortcutsService to the exported API #67

Closed
thoussem opened this issue Apr 28, 2020 · 2 comments · Fixed by #74
Closed

add the KeyboardShortcutsService to the exported API #67

thoussem opened this issue Apr 28, 2020 · 2 comments · Fixed by #74
Assignees
Labels
feature feature request

Comments

@thoussem
Copy link

Is your feature request related to a problem? Please describe.
I have to add the 'ng-keyboard-shortcuts' component every time i want to subscribe to a shortcut:

<ng-keyboard-shortcuts></ng-keyboard-shortcuts>
-----
@ViewChild(KeyboardShortcutsComponent, { static: false })
private keyboard: KeyboardShortcutsComponent;
-----
this.keyboard.select('del').subscribe(_ => {
   // do something
});

Describe the solution you'd like
Inject directly the service and use it:

constructor(private keyboard: KeyboardShortcutsService) {}
-----
this.keyboard.select('del')
@omridevk omridevk added the feature feature request label Apr 28, 2020
@omridevk omridevk self-assigned this Apr 28, 2020
@omridevk
Copy link
Owner

@thoussem
Thank you for your suggestion, older version of the library used to work with a service, but I have decided to have more to a more declarative API and I have left the select option to keep backward compatible.
I was wondering what is the use case? of using the select and not adding an action directly to the shortcut?
not that I am against your suggestion, it could make sense to expose such service given that it is only exposes one method, select.

@omridevk
Copy link
Owner

omridevk commented Apr 28, 2020

I mean I am thinking of deprecating the select method on the component and directives, I my self couldn't find a useful case for it. as you can always make a subject and next on it with the event inside the command callback. but again, I assume your use case is valid so I might choose to expose such service, it just I want to keep the surface level of the API as thin as possible and as declarative as possible, and users not have to think about services and life cycles, destruction of events etc...

@omridevk omridevk linked a pull request Jul 11, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants