Replace `on` with `once` in middleware examples

Fix the jsdox for `app.installMiddleware` to use `app.once` for
listening on 'middleware:*' events.

The previous doc version using `on` was a sort of preliminary
pessimisation, becase the event handlers would stay in the heap
for the whole life-time of the app, even though they won't be called
more than once.
This commit is contained in:
Miroslav Bajtoš 2014-01-14 08:07:47 +01:00
parent 1f80164e69
commit 8573d01c16
1 changed files with 3 additions and 3 deletions

View File

@ -451,7 +451,7 @@ function tryReadConfig(cwd, fileName) {
*
* Usage:
* ```js
* app.on('middleware:preprocessors', function() {
* app.once('middleware:preprocessors', function() {
* app.use(loopback.limit('5.5mb'))
* });
* ```
@ -461,7 +461,7 @@ function tryReadConfig(cwd, fileName) {
*
* Usage:
* ```js
* app.on('middleware:handlers', function() {
* app.once('middleware:handlers', function() {
* app.use('/admin', adminExpressApp);
* app.use('/custom', function(req, res, next) {
* res.send(200, { url: req.url });
@ -483,7 +483,7 @@ function tryReadConfig(cwd, fileName) {
* ```js
* var bunyan = require('bunyan');
* var log = bunyan.createLogger({name: "myapp"});
* app.on('middleware:error-loggers', function() {
* app.once('middleware:error-loggers', function() {
* app.use(function(err, req, res, next) {
* log.error(err);
* next(err);