This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 388
added generic for EventEmitter to allow Custom EventKeys like an enum… #134
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ad6d91c
added generic for EventEmitter to allow Custom EventKeys like an enum…
wartoshika 47831a9
Merge branch 'master' into master
Olical b5f84e8
Correct emit rest args.
Olical 3f56355
Correct emit args again
Olical e27cd79
Finally got emit right, editing through GitHub UI
Olical File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
<E = EventKey>
turnsEventEmitter
into a generic class with a type variable that defaults toEventKey
if not provided? (I don't know TS, so I'm speculating! 😄)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is ture. If no generic type if given,
EventKey
is used. But is there is any given,E
will turn to need the given value. Typescript genric works like any other generic languages.I' ll test providing no value to the generic type resulting is need a type of
KeyEvent
and providing eg. an enum type will result in requireing a typeof of enum given to the generic pattern.You have to know that this default type
KeyEvent
will only allow a backwards compatiblity at typescript >= 2.3. but typescript ^2.4 is at current stable.I hope this meight help