mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 14:54:21 +01:00
Allow users to use .on and .once as non-decorators methods.
This commit is contained in:
@@ -125,22 +125,26 @@ class BfxWebsocketClient(object):
|
|||||||
if all(bucket.websocket != None and bucket.websocket.open == True for bucket in self.buckets):
|
if all(bucket.websocket != None and bucket.websocket.open == True for bucket in self.buckets):
|
||||||
self.event_emitter.emit("open")
|
self.event_emitter.emit("open")
|
||||||
|
|
||||||
def on(self, event):
|
def on(self, event, callback = None):
|
||||||
if event not in BfxWebsocketClient.EVENTS:
|
if event not in BfxWebsocketClient.EVENTS:
|
||||||
raise EventNotSupported(f"Event <{event}> is not supported. To get a list of available events print BfxWebsocketClient.EVENTS")
|
raise EventNotSupported(f"Event <{event}> is not supported. To get a list of available events print BfxWebsocketClient.EVENTS")
|
||||||
|
|
||||||
|
if callback != None:
|
||||||
|
return self.event_emitter.on(event, callback)
|
||||||
|
|
||||||
def handler(function):
|
def handler(function):
|
||||||
self.event_emitter.on(event, function)
|
self.event_emitter.on(event, function)
|
||||||
|
|
||||||
return handler
|
return handler
|
||||||
|
|
||||||
def once(self, event):
|
def once(self, event, callback = None):
|
||||||
if event not in BfxWebsocketClient.EVENTS:
|
if event not in BfxWebsocketClient.EVENTS:
|
||||||
raise EventNotSupported(f"Event <{event}> is not supported. To get a list of available events print BfxWebsocketClient.EVENTS")
|
raise EventNotSupported(f"Event <{event}> is not supported. To get a list of available events print BfxWebsocketClient.EVENTS")
|
||||||
|
|
||||||
|
if callback != None:
|
||||||
|
return self.event_emitter.once(event, callback)
|
||||||
|
|
||||||
def handler(function):
|
def handler(function):
|
||||||
self.event_emitter.once(event, function)
|
self.event_emitter.once(event, function)
|
||||||
|
|
||||||
return handler
|
return handler
|
||||||
|
|
||||||
class _BfxWebsocketBucket(object):
|
class _BfxWebsocketBucket(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user