Skip to content

Commit

Permalink
Add calls to flush_ui_queue for Hermes (#4579)
Browse files Browse the repository at this point in the history
Rearranged jsi_init
  • Loading branch information
kraenhansen committed Jun 8, 2022
1 parent 62a5b21 commit 0c4dff1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
20 changes: 15 additions & 5 deletions src/jsi/jsi_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,43 @@ namespace js {
template <>
inline JsiVal realmjsi::Function::call(JsiEnv env, const JsiFunc& function, size_t argc, const JsiVal arguments[])
{
return env(function->call(env, env.args(arguments, argc), argc));
auto result = env(function->call(env, env.args(arguments, argc), argc));
flush_ui_queue();
return result;
}

template <>
inline JsiVal realmjsi::Function::call(JsiEnv env, const JsiFunc& function, const JsiObj& this_object, size_t argc,
const JsiVal arguments[])
{
return env(function->callWithThis(env, this_object, env.args(arguments, argc), argc));
auto result = env(function->callWithThis(env, this_object, env.args(arguments, argc), argc));
flush_ui_queue();
return result;
}

template <>
inline JsiVal realmjsi::Function::callback(JsiEnv env, const JsiFunc& function, size_t argc, const JsiVal arguments[])
{
return env(function->call(env, env.args(arguments, argc), argc));
auto result = env(function->call(env, env.args(arguments, argc), argc));
flush_ui_queue();
return result;
}
template <>
inline JsiVal realmjsi::Function::callback(JsiEnv env, const JsiFunc& function, const JsiObj& this_object,
size_t argc, const JsiVal arguments[])
{
return env(function->callWithThis(env, this_object, env.args(arguments, argc), argc));
auto result = env(function->callWithThis(env, this_object, env.args(arguments, argc), argc));
flush_ui_queue();
return result;
}

template <>
inline JsiObj realmjsi::Function::construct(JsiEnv env, const JsiFunc& function, size_t argc,
const JsiVal arguments[])
{
return env(function->callAsConstructor(env, env.args(arguments, argc), argc).asObject(env));
auto result = env(function->callAsConstructor(env, env.args(arguments, argc), argc).asObject(env));
flush_ui_queue();
return result;
}

} // namespace js
Expand Down
6 changes: 0 additions & 6 deletions src/jsi/jsi_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@

#include "jsi_init.hpp"

namespace realm {
namespace js {
std::function<void()> flush_ui_queue;
} // namespace js
} // namespace realm

#if !REALM_ENABLE_SYNC
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "crypt32")
Expand Down
8 changes: 8 additions & 0 deletions src/jsi/jsi_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@

#pragma once

#include <functional>

namespace realm {
namespace js {
std::function<void()> flush_ui_queue;
} // namespace js
} // namespace realm

#include "jsi_string.hpp"
#include "jsi_protected.hpp"
#include "jsi_function.hpp"
Expand Down

0 comments on commit 0c4dff1

Please sign in to comment.