1 #pragma once 2 3 #include <jsi/jsi.h> 4 #include <memory> 5 #include <string> 6 #include <utility> 7 8 #include "Shareables.h" 9 10 using namespace facebook; 11 12 namespace reanimated { 13 14 class EventHandlerRegistry; 15 16 class WorkletEventHandler { 17 friend EventHandlerRegistry; 18 19 private: 20 std::shared_ptr<JSRuntimeHelper> _runtimeHelper; 21 uint64_t id; 22 std::string eventName; 23 jsi::Value _handlerFunction; 24 25 public: WorkletEventHandler(const std::shared_ptr<JSRuntimeHelper> & runtimeHelper,uint64_t id,std::string eventName,jsi::Value && handlerFunction)26 WorkletEventHandler( 27 const std::shared_ptr<JSRuntimeHelper> &runtimeHelper, 28 uint64_t id, 29 std::string eventName, 30 jsi::Value &&handlerFunction) 31 : _runtimeHelper(runtimeHelper), 32 id(id), 33 eventName(eventName), 34 _handlerFunction(std::move(handlerFunction)) {} 35 void process(double eventTimestamp, const jsi::Value &eventValue); 36 }; 37 38 } // namespace reanimated 39