Skip to content

Commit

Permalink
Add test utilities for C++ and Java
Browse files Browse the repository at this point in the history
Summary:
@public

Test utility on top of the new event system that maintains a counter of instantiated nodes. Meant to replace the global node counter.

Reviewed By: SidharthGuglani

Differential Revision: D15174855

fbshipit-source-id: 6998472f95a09b8da652257a26596164bdcf43d6
  • Loading branch information
davidaurelio authored and facebook-github-bot committed May 9, 2019
1 parent d1411cc commit 03bf178
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ReactCommon/yoga/yoga/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ std::function<Event::Subscriber>& globalEventSubscriber() {

} // namespace

void Event::reset() {
globalEventSubscriber() = nullptr;
}

void Event::subscribe(std::function<Subscriber>&& subscriber) {
if (globalEventSubscriber() != nullptr) {
throw std::logic_error(
Expand Down
2 changes: 2 additions & 0 deletions ReactCommon/yoga/yoga/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct Event {
};
};

static void reset();

static void subscribe(std::function<Subscriber>&& subscriber);

template <Type E>
Expand Down

0 comments on commit 03bf178

Please sign in to comment.