nimiqclient.callback.Callback

class nimiqclient.callback.Callback(callback_function, kwargs, result_decoder=typing.Union[typing.Callable[[typing.Dict], ~T], NoneType])[source]

Bases: Generic[T]

Callback to be used by the NimiqClient when calling a method that subscribes to specific events

Parameters:

callback_function (Callable[[Any, TypeVar(T), Dict], Awaitable[None]]) – Callback function to be called by the client when the subscribed event happens.

:type Callable[[Any, T], Awaitable[None]] :type result_decoder: :param result_decoder: Function to be called when the result of an RPC

call must be decoded before passing it to the callback

:type Optional[Callable[[dict], T]] :type kwargs: Dict :param kwargs: Function arguments to be sent to the callback when called. :type kwargs: dict

Methods

call

Calls a callback with the appropriate arguments

async call(client, result)[source]

Calls a callback with the appropriate arguments

Parameters:
  • client (NimiqClient) – Nimiq client to be passed to the callback.

  • result (int or str or dict) – Result of the RPC call done by the NimiqClient