hololinked.client.abstractions.ConsumedThingEvent
Client side event subscription abstraction. Subclass from here to implement protocol specific event subscription.
Source code in hololinked/hololinked/client/abstractions.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
Functions
__init__
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
EventAffordance
|
dataclass object representing the event |
required |
|
BoundLogger
|
logger instance |
required |
|
Any
|
the parent object that owns this event |
required |
Source code in hololinked/hololinked/client/abstractions.py
subscribe
subscribe(callbacks: list[Callable] | Callable, asynch: bool = False, concurrent: bool = False, deserialize: bool = True) -> None
subscribe to the event
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Callable] | Callable
|
callback or list of callbacks to add |
required |
|
bool
|
whether to start an async(-io task) event listener instead of a threaded listener |
False
|
|
bool
|
|
False
|
|
bool
|
if |
True
|
Source code in hololinked/hololinked/client/abstractions.py
unsubscribe
listen
Listen to events and call the callbacks. This method needs to be invoked by the subscribe() method
in threaded mode. Use async_listen() for asyncio mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Form
|
form to use for event subscription |
required |
|
list[Callable]
|
list of callbacks to call on event |
required |
|
bool
|
whether to run each callback concurrently in a separate thread |
True
|
|
bool
|
whether to deserialize the event payload before passing to callbacks |
True
|
Source code in hololinked/hololinked/client/abstractions.py
async_listen
async
async_listen(form: Form, callbacks: list[Callable], concurrent: bool = True, deserialize: bool = True)
Listen to events and call the callbacks. This method needs to be invoked by the subscribe() method
in asyncio mode. Use listen() for threaded mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Form
|
form to use for event subscription |
required |
|
list[Callable]
|
list of callbacks to call on event |
required |
|
bool
|
whether to run each callback concurrently as separate tasks |
True
|
|
bool
|
whether to deserialize the event payload before passing to callbacks |
True
|
Source code in hololinked/hololinked/client/abstractions.py
schedule_callbacks
schedule the callbacks to be called with the event data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Callable]
|
list of callbacks to call |
required |
|
Any
|
event data to pass to the callbacks |
required |
|
bool
|
whether to run each callback in a separate thread |
False
|
Source code in hololinked/hololinked/client/abstractions.py
async_schedule_callbacks
async
async schedule the callbacks to be called with the event data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list of callbacks to call |
required | |
|
Any
|
event data to pass to the callbacks |
required |
|
bool
|
whether to run each callback in a separate thread |
False
|
Source code in hololinked/hololinked/client/abstractions.py
add_callbacks
add callbacks to the event
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Callable] | Callable
|
callback or list of callbacks to add |
required |