Add additional type info to messageRouter

This commit is contained in:
hensm
2019-04-10 05:34:17 +01:00
parent 40d19da638
commit 7a36160bf2
2 changed files with 19 additions and 6 deletions

View File

@@ -1,6 +1,15 @@
"use strict";
type SenderCallback = (message: any, details: any) => void;
import { Message } from "../types";
interface Details {
tabId: number
, frameId: number
}
type SenderCallback = (message: Message, details: Details) => void;
const routeMap = new Map<string, SenderCallback>();
@@ -12,7 +21,7 @@ function deregister (routeName: string) {
routeMap.delete(routeName);
}
function handleMessage (message: any, details?: any) {
function handleMessage (message: Message, details?: Details) {
const destination = message.subject.split(":")[0];
if (routeMap.has(destination)) {
routeMap.get(destination)(message, details);