Added unsubscribe return function to wsProvider.on() (#1780)

* Added unsubscribe return function to wsProvider.on()

* Updated mocks, added noop to http provider
This commit is contained in:
Jakub Pánik
2020-01-30 16:48:11 +01:00
committed by GitHub
parent 65ff5c8f30
commit 59e069f091
4 changed files with 14 additions and 4 deletions
+5 -1
View File
@@ -167,9 +167,13 @@ export default class WsProvider implements WSProviderInterface {
* @summary Listens on events after having subscribed using the [[subscribe]] function.
* @param {ProviderInterfaceEmitted} type Event
* @param {ProviderInterfaceEmitCb} sub Callback
* @return unsubscribe function
*/
public on (type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): void {
public on (type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void {
this._eventemitter.on(type, sub);
return (): void => {
this._eventemitter.removeListener(type, sub);
};
}
/**