Skip to content

Middleware API #47

Open
Open
@jnv

Description

@jnv

This could be used to implement: #39, #25, #44.

  • Setup globally, for program
  • Wraps each box in a flow
  • Receives an instance of box and its metadata, can (re-)call it

Activity

jnv

jnv commented on Jan 21, 2019

@jnv
ContributorAuthor

Since box can emit unlimited amount of messages, a plain Koa-like middleware won't cut it. We can use generators though and yield to the middleware. The user-level API may look like this:

function myFancyMiddleware (ctx, next) {
  // do something before the box is called
  for (let message of next()) {
    // do something with message
    // pass the message up the middleware chain
    yield message
  }
  // do something once the box is done
}
self-assigned this
on Jan 21, 2019
jnv

jnv commented on Jan 21, 2019

@jnv
ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

    Participants

    @jnv

    Issue actions

      Middleware API · Issue #47 · Emplifi/BakeryJS