diff --git a/ReactCommon/fabric/events/EventBeat.cpp b/ReactCommon/fabric/events/EventBeat.cpp index 8dd62828b..48d175ec5 100644 --- a/ReactCommon/fabric/events/EventBeat.cpp +++ b/ReactCommon/fabric/events/EventBeat.cpp @@ -34,5 +34,9 @@ void EventBeat::setBeatCallback(const BeatCallback &beatCallback) { beatCallback_ = beatCallback; } +void EventBeat::setFailCallback(const FailCallback &failCallback) { + failCallback_ = failCallback; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/events/EventBeat.h b/ReactCommon/fabric/events/EventBeat.h index ef518eba5..14eababdd 100644 --- a/ReactCommon/fabric/events/EventBeat.h +++ b/ReactCommon/fabric/events/EventBeat.h @@ -24,6 +24,7 @@ public: virtual ~EventBeat() = default; using BeatCallback = std::function; + using FailCallback = std::function; /* * Communicates to the Beat that a consumer is waiting for the coming beat. @@ -44,11 +45,19 @@ public: virtual void induce() const; /* - * Sets a callback function. + * Sets the beat callback function. * The callback is must be called on the proper thread. */ void setBeatCallback(const BeatCallback &beatCallback); + /* + * Sets the fail callback function. + * Called in case if the beat cannot be performed anymore because of + * some external circumstances (e.g. execution thread is beling destructed). + * The callback can be called on any thread. + */ + void setFailCallback(const FailCallback &failCallback); + protected: /* * Should be used by sublasses to send a beat. @@ -57,6 +66,7 @@ protected: void beat() const; BeatCallback beatCallback_; + FailCallback failCallback_; mutable std::atomic isRequested_ {false}; };