Prepare Emitter API to go public
See original GitHub issueIn preparation for #3619 and #3620 I’d live to review out Emitter API and rename some things to better match our own internal naming. I think the original was a bit too specific with regards to internal implementations and the new version should be a little more abstract:
Old:
addKeyword(text, scope)
addText(text)
addSublanguage(emitter, subLanguageName)
finalize()
openNode(scope)
closeNode()
closeAllNodes()
toHTML()
New:
addText(text)
startScope(scope)
(or pushScope?)endScope()
(or popScope? or finishScope?)__addSublanguage(emitter, subLanguageName)
- (may stay private)finalize()
- thoughts on naming?toHTML()
Removed:
- <del>
addKeyword(text, scope)
</del> - pull back into an internal helper - <del>
closeAllNodes()
</del> - Lets just let finalize be responsible for all cleanup.
For writing custom grammar parsers one would really only need to concern themselves with 3 API calls I think:
- addText
- startScope
- endScope
@wooorm I know you had plenty of thoughts on this before… it’s possible I’m a little more receptive now… I do plan on reducing a API a bit if we’re going public (which I recall you pushed for previously).
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to code your own event emitter in Node.js: a step-by-step ...
Grab the array of listeners by 'event'; If none found return 'this' for chaining. · Return 'this' to continue chaining. ; Get the...
Read more >EventEmitter - Angular
Creates an instance of this class that can deliver events synchronously or asynchronously. This class is "final" and should not be extended. See...
Read more >What is the proper use of an EventEmitter? - Stack Overflow
Yes, go ahead and use it. EventEmitter is a public, documented type in the final Angular Core API. Whether or not it is...
Read more >Understanding Event Emitters | CSS-Tricks
An event emitter is a pattern that listens to a named event, fires a callback, then emits that event with a value. Sometimes...
Read more >React Native Event Emitter with Swift - gists · GitHub
I had to do the following to get this to work out-of-the-box: In EventEmitter.swift, make eventEmitter non-static by changing: private static var eventEmitter: ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s what #3620 allows. It should land in 11.7 (as a beta feature) with a full release with v12.
@joshgoebel as long as there are ways to bypass the default tokenizer and there is a way to provide the actual token (parsed with an external parser), my addon is fine. I don’t have the time at this point to test it, but I will do it once it is live.
This is part of error recovery. The approach can be simple or complex. A simple approach is discard everything (eg highlight as default text) until a valid sequence is found, then start again.