Audacity 3.2.0
Namespaces | Classes | Functions
AppEvents Namespace Reference

Namespaces

namespace  anonymous_namespace{AppEvents.cpp}
 

Classes

class  ProviderBase
 

Functions

void OnAppInitialized (std::function< void()> callback)
 
void OnAppClosing (std::function< void()> callback)
 
Observer::Subscription OnAppIdle (std::function< void()> callback)
 

Function Documentation

◆ OnAppClosing()

UTILITY_API void AppEvents::OnAppClosing ( std::function< void()>  callback)

Register callback to be called when application is closing.

Parameters
callbackCallback to be called when application is initialized.
Precondition
!!calback

Definition at line 57 of file AppEvents.cpp.

58{
59 assert(callback);
60
61 if (!callback)
62 return;
63
64 auto& handlers = GetEventHandlers();
65
66 if (handlers.AppClosingCalled)
67 callback();
68 else
69 handlers.appClosing.push_back(std::move(callback));
70}

References AppEvents::anonymous_namespace{AppEvents.cpp}::GetEventHandlers().

Referenced by audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncHousekeeper.cpp}::Housekeeper::Housekeeper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnAppIdle()

UTILITY_API Observer::Subscription AppEvents::OnAppIdle ( std::function< void()>  callback)

Register callback to be called when application is idle.

Parameters
callbackCallback to be called when application is idle.
Precondition
!!calback

Definition at line 72 of file AppEvents.cpp.

73{
74 return GetEventHandlers().Subscribe([callback = std::move(callback)](auto&)
75 { callback(); });
76}
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199

References AppEvents::anonymous_namespace{AppEvents.cpp}::GetEventHandlers(), and Observer::Publisher< Message, NotifyAll >::Subscribe().

Here is the call graph for this function:

◆ OnAppInitialized()

UTILITY_API void AppEvents::OnAppInitialized ( std::function< void()>  callback)

Register callback to be called when application is initialized. If application is already initialized, callback will be called immediately.

Parameters
callbackCallback to be called when application is initialized.
Precondition
!!calback

Definition at line 42 of file AppEvents.cpp.

43{
44 assert(callback);
45
46 if (!callback)
47 return;
48
49 auto& handlers = GetEventHandlers();
50
51 if (handlers.AppInitializedCalled)
52 callback();
53 else
54 handlers.appInitialized.push_back(std::move(callback));
55}

References AppEvents::anonymous_namespace{AppEvents.cpp}::GetEventHandlers().

Referenced by audacity::cloud::audiocom::sync::anonymous_namespace{CloudSyncHousekeeper.cpp}::Housekeeper::Housekeeper(), and anonymous_namespace{ProjectStatus.cpp}::Dispatcher::NewFieldRegistered().

Here is the call graph for this function:
Here is the caller graph for this function: