hdk-grid 0.0.1
Header-only foundational library for the Hollow Development Kit.
Loading...
Searching...
No Matches
TapScope Class Reference

RAII container for managing multiple subscriptions as a group. More...

Detailed Description

RAII container for managing multiple subscriptions as a group.

TapScope simplifies managing multiple related subscriptions by collecting them in one object. When the TapScope is destroyed or DetachAll() is called, all contained subscriptions are automatically unsubscribed.

This is useful for managing event subscriptions tied to an object's lifetime - simply add all subscriptions to a TapScope member and they'll be cleaned up automatically when the object is destroyed.

Features:

  • Add multiple subscriptions from different dispatchers
  • Automatic cleanup of all subscriptions on destruction
  • Thread-safe subscription management
  • Move-only semantics

Example usage:

class MyWidget {
private:
Conduit<int> on_click;
Conduit<std::string> on_text_changed;
hdk::grid::TapScope subscriptions;
public:
MyWidget() {
subscriptions.Add(on_click.Attach([](int button) { ... }));
subscriptions.Add(on_text_changed.Attach([](const std::string& text) { ... }));
}
// Subscriptions automatically unsubscribed when MyWidget is destroyed
};
Generic event dispatcher template for publish-subscribe pattern.

The documentation for this class was generated from the following file: