Molybden API
Loading...
Searching...
No Matches
molybden::Delegate< Args, Action > Class Template Reference

Delegates allow you to make decisions that affect the application behavior. More...

#include <delegate.hpp>

Public Types

using Signature = void(const Args &args, Action action)
 The callback's signature.
 

Public Member Functions

Delegateoperator= (std::function< Signature > callback)
 Registers a callback to be invoked by this delegate.
 
void reset ()
 Resets the callback registered for this delegate.
 

Friends

class ObservableOwner
 

Detailed Description

template<typename Args, typename Action>
class molybden::Delegate< Args, Action >

Delegates allow you to make decisions that affect the application behavior.

Every time when Molybden reaches a point when the client decision is required, it invokes the corresponding delegate. If there is no delegate registered, Molybden performs the default action described in the delegate's documentation.

Delegates are usually blocking. It means that the calling thread in the underlying Chromium engine is blocked until you decide how to proceed using the action parameter passed to the delegate.

Template Parameters
Argsthe type of the callback arguments.
Actionthe action passed to the callback.

Member Function Documentation

◆ operator=()

template<typename Args , typename Action >
Delegate< Args, Action > & molybden::Delegate< Args, Action >::operator= ( std::function< Signature callback)

Registers a callback to be invoked by this delegate.

Use the following approach to register a callback:

delegate = [](const Args& args, Action action) {};
The base API that implements classes which represent delegate's action.
Definition delegate_action.hpp:18

In order to unregister the callback, use the reset() method:

delegate.reset();

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