Convert ext lib to typescript

This commit is contained in:
hensm
2019-02-27 16:46:09 +00:00
parent 7eaa97a556
commit 8cef999afb
6 changed files with 58 additions and 31 deletions

View File

@@ -0,0 +1,26 @@
"use strict";
type SenderCallback = (message: any, details: any) => void;
const routeMap = new Map<string, SenderCallback>();
function register (routeName: string, senderCallback: SenderCallback) {
routeMap.set(routeName, senderCallback);
}
function deregister (routeName: string) {
routeMap.delete(routeName);
}
function handleMessage (message: any, details?: any) {
const destination = message.subject.split(":")[0];
if (routeMap.has(destination)) {
routeMap.get(destination)(message, details);
}
}
export default {
register
, deregister
, handleMessage
};