mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 23:57:25 +00:00
LibCore: Add Core::deferred_invoke_if(F, Condition)
This will invoke the function F only if the provided Condition is met, otherwise the execution of the function F will be further deferred.
This commit is contained in:
committed by
Andreas Kling
parent
68a1a78a1a
commit
a362c37c8b
@@ -13,8 +13,21 @@ namespace Core {
|
||||
|
||||
class DeferredInvocationContext final : public Core::EventReceiver {
|
||||
C_OBJECT(DeferredInvocationContext)
|
||||
public:
|
||||
bool should_invoke() const { return m_condition(); }
|
||||
|
||||
private:
|
||||
DeferredInvocationContext() = default;
|
||||
DeferredInvocationContext()
|
||||
: m_condition([] { return true; })
|
||||
{
|
||||
}
|
||||
|
||||
DeferredInvocationContext(Function<bool()> condition)
|
||||
: m_condition(move(condition))
|
||||
{
|
||||
}
|
||||
|
||||
Function<bool()> m_condition;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user