blob: ca8243969db840a3b09dfc5f6c74b1744f6fbbfb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { injectable } from "tsyringe";
type OnConnectFunc = (port: browser.runtime.Port) => void;
type OnDisconnectFunc = (port: browser.runtime.Port) => void;
@injectable()
export default class FindPortListener {
constructor(
private readonly onConnect: OnConnectFunc,
private readonly onDisconnect: OnDisconnectFunc
) {}
run(): void {
browser.runtime.onConnect.addListener((port) => {
if (port.name !== "vimvixen-find") {
return;
}
port.onDisconnect.addListener(this.onDisconnect);
this.onConnect(port);
});
}
}
|