remi-runner

2018-10-11 admin

remi-runner是什么

什么是remi-runner,A remi extension that allows registering plugins that are returning promises during their registration or are registered synchronously

remi-runner使用教程帮助文档

remi-runner

A remi extension that allows registering plugins that are returning promises during their registration or are registered synchronously

Dependency Status Build Status npm version Coverage Status

Installation

npm install remi-runner

Example Usage

const remi = require('remi')
const remiRunner = require('remi-runner')

const app = {}
const registrator = remi(app)

registrator.hook(remiRunner())

registrator.register([cbPlugin, promisePlugin, syncPlugin])

// a traditional plugin that uses an error-first-callback
// this will work w/o using the remi-runner
function cbPlugin(app, opts, next) {
  // ...
  next()
}

cbPlugin.attributes = { name: 'cbPlugin' }

// a plugin that returns a Promise. This type of plugin will be registered correctly
// only if remi is hooked with remi-runner
function promisePlugin(app, opts) {
  // ...
  return Promise.resolve()
}

cbPlugin.attributes = { name: 'promisePlugin' }

// a synchronous plugin. This type of plugin will be registered correctly
// only if remi is hooked with remi-runner
function syncPlugin(app, opts) {
  // ...
}

cbPlugin.attributes = { name: 'syncPlugin' }

License

MIT © Zoltan Kochan

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-42398.html

文章标题:remi-runner

回到顶部