GeezerVison is showing github.com — [Implement] Naive basic EventEmitter class by jtenner · Pull Request #18 · AssemblyScript/node
Conversation
jtenner
commented
Jul 25, 2019
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Let me start by saying I realize how entirely dangerous this is. Currently there's no good ergonomic way to do this, and in order to implement the backbone of the Stream classes, we need something that resembles an emitter.
Current Limitations:
- Callback signatures must match runtime assertions
EventEmitter is treated as abstract
- Callback parameters up to length
10
- callback must return
void
- Emit still too large. Requires switch statement to determine callback argument length
- emit function doesn't match @types/node type arguments. It still requires explicit types
emitter.emit<A, B, C, D>(a: A, b: B, c: C, d: D); // etc.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
jtenner
commented
Jul 25, 2019
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Now the implementation contains a groked callback type verifier that does runtime checking of callback signatures. It requires a global map that contains a set of valid signatures for each event, and is registered once per EventEmitter class extension.
Not done:
-
EventEmitter should be abstract.
- Docs needs to be updated for this class so that others can learn how to use this class effectively
- Wait for compiler to support variable argument lengths or inferring of argument length count
- will be a 64bit integer with both the id and the argument length combined
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@dcodeIO conflicts aside, what's holding this request back? I just need to fix the builtin request. Right?
Other than that, not sure how to make this better.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
dcodeIO
Awaiting requested review from dcodeIO
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.