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

Difference between this.queue, this._queue, and queue? #3

Open
davidschachter opened this issue Oct 1, 2020 · 1 comment
Open

Difference between this.queue, this._queue, and queue? #3

davidschachter opened this issue Oct 1, 2020 · 1 comment

Comments

@davidschachter
Copy link

Ah, I get it:

  • queue is a method of the class
  • this._queue is a call to that method
  • this.queue is a queue of SpeechSynthesisUtterance objects and silent audio spacer objects

Perhaps change the name of _queue to _addToQueue so it's clearly an action rather than an object (a verb, not a noun).

@guest271314
Copy link
Owner

At

this.queue = [];

JavaScript Array to store Promise objects resolved at onend event of SpeechSynthesisUtterance

_queue({ utterance }) {

Method defined at the class Push current SpeechSynthesisUtterance to this.queue Array.

Given that English is an equivocal language "queue" can take the form of at least noun and, or verb. The underscore character before the method definition is intended to convey internal usage, not necessarily to be exposed to user, while queue the array is exposed mainly for the purpose of cancelling the actual internal queue of the speech synthesis interface with cancel(), in this case speech-dispatcher, thus queue = [] and _queue(){} with coexist as distinct noun and verb with former being JavaScript Array storage for latter anonymous asynchronous functions that return a Promise object.

Does the above detail provide sufficient disambiguation?

If the above description is not sufficient to for disambiguation, would suggest following Streams Standard re the method ReadableStreamDefaultController.enqueue(), for example, substitute _enqueue() for _queue(), however, we are not actually returning any value here, as speak() does not output values the user has access to per the specifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants