deanrad / antares-ts

Antares is an Architecture for making real-time applications with confidence.
https://deanius.github.io/antares/
MIT License
2 stars 0 forks source link

Allow Reordering of agent arguments #72

Closed deanrad closed 6 years ago

deanrad commented 6 years ago

Via an on alias to addRenderer..

agent.on('search/messages', searchMessages('search/message/success'))
agent.on('search/message/success', getMessageBody('message/body/success'))
agent.on('message/body/success', getAttachmentBody('message/attachment/success'), {
  concurrency: 'serial'
})
agent.on('message/attachment/success', playIt('audio/play'), {
  concurrency: 'serial'
})

instead of below.

Rationale- renderers should be late-bound to the types they send out.. They're better off delivering payloads.. Handlers' jobs is to bundle payloads into actions, and thus handlers accept a type as an argument, and return a renderer bound over that type..

agent.addRenderer(searchMessages('search/message/success'), { actionsOfType: 'search/messages' })
      agent.addRenderer(getMessageBody('message/body/success'), { actionsOfType: 'search/message/success' })
      agent.addRenderer(getAttachmentBody('message/attachment/success'), {
        actionsOfType: 'message/body/success',
        concurrency: 'serial'
      })
      agent.addRenderer(playAttachment, { actionsOfType: 'message/attachment/success', concurrency: 'serial' })
      agent.addRenderer(showNowPlaying, { actionsOfType: /audio\/play/ })