-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
docs(middleware): updating the middleware guide with setTech and other corrections #4926
Conversation
…d adding some corrections
docs/guides/middleware.md
Outdated
|
||
## Understanding Middleware | ||
|
||
Middleware are functions that return an object with methods matching those on the `Tech`. There are currently a limited set of allowed methods that will be understood by middleware. These are: `buffered`, `currentTime`, `setCurrentTime`, `duration`, `seekable`, `played`, `play`, `pause` and `paused`. | ||
Middleware are functions that return an object, a class instance, a prototype, e.c.t, scoped to the Player with methods matching those on the `Tech`. There are currently a limited set of allowed methods that will be understood by middleware. These are: `buffered`, `currentTime`, `setCurrentTime`, `duration`, `seekable`, `played`, `play`, `pause` and `paused`. These allowed methods are split into three categories: [getters](#middleware-getters), [setters](#middleware-setters), and [mediators](#middleware-mediators). |
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.
Is e.c.t a correct stylization? I usually see etc.
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.
whoops, good catch. I often make this mistake
* [Middleware Setters](#middleware-setters) | ||
* [Middleware Getters](#middleware-getters) | ||
* [Middleware Mediators](#middleware-mediators) | ||
* [Termination and Mediators](#termination-and-mediators) | ||
* [Using Middleware](#using-middleware) | ||
* [Terminating Mediator Methods](#terminating-mediator-methods) | ||
* [setSource](#setsource) | ||
|
||
## Understanding Middleware |
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.
I suggest starting out with a purpose statement for readers who have arrived at this page with no context. Something like "Middleware allows you to override the behavior of basic player methods."
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.
That's actually at the top of the file 😄
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.
Doh, missed that. Looks good!
|
||
``` | ||
|
||
Mediators make a round trip: starting at the `Player`, mediating to the `Tech` and returning the result to the `Player` again. A `call{method}` method must be supplied by the middleware which is used when mediating to the `Tech`. On the way back to the `Player`, the `{method}` will be called instead, with 2 arguments: `terminated`, a Boolean indicating whether a middleware terminated during the mediation to the tech portion, and `value`, which is the value returned from the `Tech`. A barebones example of a middleware with Mediator methods is: | ||
A skeleton of a middleware with Mediator methods is given below: |
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.
I noticed that this example uses callPlay
and pause
. Should the pause
be play
?
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.
good catch
docs/guides/middleware.md
Outdated
}, | ||
... | ||
setSource: function(srcObj, next) { |
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.
can we move setSource
to be the first property of the object? Since it's required and it's important to know which source it's selected with, having it first, I think, is useful.
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.
below as well
No description provided.