avg-core-ts
Version:
Develop Adventure Game (or ADV, Visual Novel, Galgame, etc.) on your own!
31 lines (29 loc) • 765 B
JavaScript
/**
* @file middleware
* @author MicroMatrix <yangpan.1985@bytedance.com>
* @copyright 2012-2020 bytedance
* @link git@code.byted.org:yangpan.1985/avg.git
*/
/**
* Middleware in AVG.js is very important,
* you can use it to gain control of the entire framework permissions,
* such as writing components or plug-ins
*
* Example, you want plug your own data in saving archives, you should write a middleware like this:
* ```js
* async function saveMiddleware(ctx, next) {
* ctx.data.myKey = myValue;
* await next();
* }
*
* AVG.core.use('save-archive', saveMiddleware);
* ```
*
* or just:
* ```js
* AVG.core.use('save-archive', async (ctx, next) => {
* ctx.data.myKey = myValue;
* await next();
* });
* ```
*/