/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCommon/react/renderer/core/EventPayload.h
53 строки
1 KB
Eric Rozell
Add EventPayload::extractValue for NativeAnimated (#49988)
18 мар 2025, 22:12
18 мар 2025, 22:12
be92588
Код
Авторство
О чём код?
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <jsi/jsi.h> #include <react/renderer/core/EventPayloadType.h> #include <optional> #include <vector> namespace facebook::react { /** * Abstract base class for all event payload types. */ struct EventPayload { virtual ~EventPayload() = default; EventPayload() = default; EventPayload(const EventPayload&) = default; EventPayload& operator=(const EventPayload&) = default; EventPayload(EventPayload&&) = default; EventPayload& operator=(EventPayload&&) = default; virtual jsi::Value asJSIValue(jsi::Runtime& runtime) const = 0; /** * Reports the type of the event payload for efficient downcasting. * When adding a new EventPayload be sure to add a new type of it * in `EventPayloadType` and return it from its overriden `getType()` method. */ virtual EventPayloadType getType() const = 0; /** * Used to extract numeric values from the event payload based on * property path names as they will exist in JavaScript. This can * be used in conjunction with listeners on EventEmitters to do * things like drive native animations. */ virtual std::optional<double> extractValue( const std::vector<std::string>& /* path */) const { return std::nullopt; } }; using SharedEventPayload = std::shared_ptr<const EventPayload>; } // namespace facebook::react