From dc2b0e014f18df3c4568588f44f111561fd3e937 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 9 Dec 2021 21:55:16 -0500 Subject: [PATCH] add subject function binders --- src/kiri/main.js | 2 +- src/moto/broker.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kiri/main.js b/src/kiri/main.js index de66101c..ed36bde2 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -16,7 +16,7 @@ SETUP = parseOpt(LOC.search.substring(1)), SECURE = isSecure(LOC.protocol), LOCAL = self.debug && !SETUP.remote, - EVENT = new Broker(), + EVENT = KIRI.broker = new Broker(), SDB = MOTO.KV, ODB = KIRI.odb = new MOTO.Storage(SETUP.d ? SETUP.d[0] : 'kiri'), // K3DB = KIRI.wdb = new MOTO.Storage('kiri3', { stores:["file","work"] }).init(), diff --git a/src/moto/broker.js b/src/moto/broker.js index d58b21c6..5259dcfd 100644 --- a/src/moto/broker.js +++ b/src/moto/broker.js @@ -46,4 +46,12 @@ class Broker { } } } + + // return function bound to a topic + bind(topic, message, options) { + let broker = this; + return function(msg = message, opt = options) { + broker.publish(topic, msg, opt); + } + } }