npm.io
1.0.0-beta6 • Published 8 years ago

experimentation-mesg-js

Licence
ISC
Version
1.0.0-beta6
Deps
2
Size
5 kB
Vulns
0
Weekly
0

MESG.js

Services

Let's take this really simple service example

name: example
events:
  eventX:
    data: {}
tasks:
  start:
    inputs:
      isValid:
        type: Boolean
    outputs:
      valid:
        data: {}
      error:
        data: {}

Listen for tasks

const MESG = require('mesg/service')

const start = ({ isValid }, { valid, error }) => isValid
  ? valid({})
  : error({})

MESG.listenTask({ start })
Emit event
const MESG = require('mesg/service')

MESG.emitEvent("eventX", {
  foo: "bar"
}).then(...)