psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::Slot< T > Class Template Reference

#include <Slot.hpp>

Inheritance diagram for psychic_ui::Slot< T >:
psychic_ui::SlotBase

Public Types

using Callback = std::function<void(const T &...)>

Public Member Functions

 Slot (std::weak_ptr< detail::SignalCore< T... > > core, Callback callback)
void disconnect () override
bool connected () const override
Public Member Functions inherited from psychic_ui::SlotBase
 SlotBase (const SlotBase &)=delete
SlotBase & operator= (const SlotBase &)=delete
 SlotBase (SlotBase &&)=delete
SlotBase & operator= (SlotBase &&)=delete

Friends

class Signal< T... >
struct detail::SignalCore< T... >

Detailed Description

template<class... T>
class psychic_ui::Slot< T >

Subscription to a signal, returned by Signal::subscribe.

The signal keeps its slots alive, so dropping the returned pointer does not disconnect: keep it in a ScopedSlot to disconnect later, or extend from Observer and use subscribeTo to disconnect when the observer dies.

Member Function Documentation

◆ connected()

template<class... T>
bool psychic_ui::Slot< T >::connected ( ) const
inlinenodiscardoverridevirtual

Whether the callback will still be called when the signal is emitted

Implements psychic_ui::SlotBase.

◆ disconnect()

template<class... T>
void psychic_ui::Slot< T >::disconnect ( )
inlineoverridevirtual

Disconnects this slot from its signal. Safe to call more than once, from inside the callback, and after the signal was destroyed.

Implements psychic_ui::SlotBase.


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