Gin
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
LambdaTimer Class Reference

Timer that calls a std::function callback instead of requiring virtual override. More...

#include <gin_asyncutilities.h>

Inherits juce::Timer.

Public Member Functions

 LambdaTimer (std::function< void()> func=nullptr)
 

Public Attributes

std::function< void()> onTimer
 

Detailed Description

Timer that calls a std::function callback instead of requiring virtual override.

LambdaTimer provides a more convenient alternative to juce::Timer by accepting a lambda or std::function for the timer callback. This eliminates the need to create a subclass or override timerCallback() for simple timer operations.

Key Features:

The onTimer function is called at the specified interval. All juce::Timer methods are available (startTimer, stopTimer, isTimerRunning, etc.).

Usage:

// Create with lambda
LambdaTimer timer([this]() {
});
timer.startTimer(100); // Call every 100ms
// Create and assign later
timer.onTimer = [this]() {
};
timer.startTimer(1000); // Call every second
// Stop timer
timer.stopTimer();
Timer that calls a std::function callback instead of requiring virtual override.
Definition gin_asyncutilities.h:53
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
See also
juce::Timer, LambdaAsyncUpdater

Constructor & Destructor Documentation

◆ LambdaTimer()

LambdaTimer::LambdaTimer ( std::function< void()>  func = nullptr)

Member Data Documentation

◆ onTimer

std::function<void()> LambdaTimer::onTimer

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