psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::ScopedSlot Class Reference

#include <Slot.hpp>

Public Member Functions

template<class S>
requires std::derived_from<S, SlotBase>
 ScopedSlot (std::shared_ptr< S > slot)
 ScopedSlot (const ScopedSlot &)=delete
ScopedSlot & operator= (const ScopedSlot &)=delete
 ScopedSlot (ScopedSlot &&other) noexcept
ScopedSlot & operator= (ScopedSlot &&other) noexcept
void disconnect ()
bool connected () const
 operator bool () const

Detailed Description

Owning slot handle: disconnects when destroyed or when another slot is assigned to it. Use it for a subscription you replace or drop, typically to a signal that outlives you:

ScopedSlot _onMouseMove;
_onMouseMove = window()->mouseMoved.subscribe([this](...) { ... }); // disconnects the previous one first

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