0.5.17 • Published 6 years ago

msg-fabric-endpoint v0.5.17

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
6 years ago

msg-fabric-endpoint

Endpoint plugin for msg-fabric-core

Examples

Creating a new hub with endpoint plugin
import FabricHubBase from 'msg-fabric-core' 

import pi_endpoint from 'msg-fabric-endpoint'
const FabricHub = FabricHubBase.plugins( pi_endpoint() )


const hub = FabricHub.create()

const ep_addr_1 = await hub.endpoint({
  on_init(ep, hub) {
    console.log('on endpoint init')
  },
  on_ready(ep, hub) {
    console.log('on endpoint ready')
  },
  on_msg({msg, pkt, reply, anon, ep, hub}) {
    console.log('on endpoint message', msg, pkt)
  },
})

// ... or ...

const ep_addr_2 = await hub.endpoint( (ep, hub) => {
  console.log('on endpoint init')

  return ({msg, pkt, reply, anon}) => {
    console.log('on endpoint message', msg, pkt)
  } })
Creating a new hub with endpoint plugin (JSY dialect)
import FabricHubBase from 'msg-fabric-core' 

import pi_endpoint from 'msg-fabric-endpoint'
const FabricHub = FabricHubBase.plugins( pi_endpoint() )


const hub = FabricHub.create()

const ep_addr_1 = await hub.endpoint @:
  on_init(ep, hub) ::
    console.log('on endpoint init')

  on_ready(ep, hub) ::
    console.log('on endpoint ready')

  on_msg({msg, pkt, reply, anon, ep, hub}) ::
    console.log('on endpoint message', msg, pkt)


// ... or ...

const ep_addr_2 = await hub.endpoint @ (ep, hub) => ::
  console.log('on endpoint init')

  return ({msg, pkt, reply, anon}) => ::
    console.log('on endpoint message', msg, pkt)

License

2-Clause BSD

0.5.17

6 years ago

0.5.16

6 years ago

0.5.15

6 years ago

0.5.14

6 years ago

0.5.13

6 years ago

0.5.12

6 years ago

0.5.10

6 years ago

0.5.7

6 years ago

0.5.6

6 years ago

0.5.4

6 years ago

0.5.2

6 years ago

0.5.0

6 years ago

0.0.0

6 years ago