You can use: const off = rpc.on('event', handler); // do any actions off(); Similarly: const unregister = rpc.register('event', handler); //do any actions unregister();