5#include "flutter/fml/synchronization/sync_switch.h"
10 const std::function<
void()>& handler) {
16 const std::function<
void()>& handler) {
17 false_handler = handler;
39 for (
Observer* observer : observers_) {
40 observer->OnSyncSwitchUpdate(
value);
46 if (std::find(observers_.begin(), observers_.end(), observer) ==
48 observers_.push_back(observer);
54 observers_.erase(std::remove(observers_.begin(), observers_.end(), observer),
static sk_sp< Effect > Create()
Observes changes to the SyncSwitch.
void AddObserver(Observer *observer) const
Threadsafe.
SyncSwitch(bool value=false)
void RemoveObserver(Observer *observer) const
Threadsafe.
void Execute(const Handlers &handlers) const
void SetSwitch(bool value)
Represents the 2 code paths available when calling |SyncSwitchExecute|.
std::function< void()> false_handler
Handlers & SetIfFalse(const std::function< void()> &handler)
Sets the handler that will be executed if the |SyncSwitch| is false.
Handlers & SetIfTrue(const std::function< void()> &handler)
Sets the handler that will be executed if the |SyncSwitch| is true.
std::function< void()> true_handler