CLEANUP after bad merge after removal of peerListener

This commit is contained in:
Norbert de Langen 2020-05-01 16:54:07 +02:00
parent 5b1d3e54a8
commit 1192b729ff
No known key found for this signature in database
GPG Key ID: 976651DA156C2825

View File

@ -5,7 +5,7 @@ import { ModuleFn } from '../index';
export interface SubAPI {
getChannel: () => Channel;
on: (type: string, cb: Listener, peer?: boolean) => () => void;
on: (type: string, cb: Listener) => () => void;
off: (type: string, cb: Listener) => void;
emit: (type: string, ...args: any[]) => void;
once: (type: string, cb: Listener) => void;
@ -16,12 +16,8 @@ export interface SubAPI {
export const init: ModuleFn = ({ provider }) => {
const api: SubAPI = {
getChannel: () => provider.channel,
on: (type, cb, peer = true) => {
if (peer) {
provider.channel.addPeerListener(type, cb);
} else {
provider.channel.addListener(type, cb);
}
on: (type, cb) => {
provider.channel.addListener(type, cb);
return () => provider.channel.removeListener(type, cb);
},