#pragma once #include #include #include #include #include #include #include #include #include namespace reanimated { using namespace facebook; using namespace react; using UpdatesBatch = std::vector, folly::dynamic>>; using RegistryMap = std::unordered_map< Tag, std::pair, folly::dynamic>>; #ifdef ANDROID struct PropsToRevert { std::shared_ptr shadowNode; std::unordered_set props; }; using PropsToRevertMap = std::unordered_map; #endif class UpdatesRegistry { public: virtual ~UpdatesRegistry() {} std::lock_guard lock() const; virtual bool isEmpty() const; folly::dynamic get(Tag tag) const; virtual void remove(Tag tag) = 0; #ifdef ANDROID bool hasPropsToRevert() const; void collectPropsToRevert(PropsToRevertMap &propsToRevertMap); #endif void flushUpdates(UpdatesBatch &updatesBatch); void collectProps(PropsMap &propsMap); UpdatesBatch getPendingUpdates(); protected: mutable std::mutex mutex_; RegistryMap updatesRegistry_; void addUpdatesToBatch( const std::shared_ptr &shadowNode, const folly::dynamic &props); folly::dynamic getUpdatesFromRegistry(const Tag tag) const; void setInUpdatesRegistry( const std::shared_ptr &shadowNode, const folly::dynamic &props); void removeFromUpdatesRegistry(Tag tag); private: UpdatesBatch updatesBatch_; void flushUpdatesToRegistry(const UpdatesBatch &updatesBatch); #ifdef ANDROID PropsToRevertMap propsToRevertMap_; void updatePropsToRevert(Tag tag, const folly::dynamic *newProps = nullptr); #endif }; } // namespace reanimated