Move YG_ENABLE_EVENTS checks to event.h

Summary:
Instead of checking whether `YG_ENABLE_EVENTS` is defined for every publish, we simply wrap the body of the `publish` function macro that delegates to the method that actually publishes the event.

This way we get

1. easier to write code where we publish events
2. more type safety when editing, enabling editors/IDEs to show errors without knowing about `YG_ENABLE_EVENTS`

Reviewed By: SidharthGuglani

Differential Revision: D16049888

fbshipit-source-id: cbf362d6f7be5053c3f377125d303b7137d6a241
This commit is contained in:
David Aurelio
2019-06-28 09:53:15 -07:00
committed by Facebook Github Bot
parent c6ae314202
commit cd5324378d
2 changed files with 2 additions and 19 deletions

View File

@@ -60,7 +60,9 @@ struct Event {
template <Type E>
static void publish(const YGNode& node, const TypedData<E>& eventData = {}) {
#ifdef YG_ENABLE_EVENTS
publish(node, E, Data{eventData});
#endif
}
template <Type E>