Permalink
Browse files

core, feat: support OnEventEmit in Trigger.

  • Loading branch information...
xicilion committed Oct 28, 2017
1 parent 1f02198 commit 3240d9dd370927aa5c29eb4f40ecfa529b05cef0
Showing with 9 additions and 2 deletions.
  1. +5 −0 fibjs/include/object.h
  2. +4 −2 fibjs/src/coroutine/Trigger.cpp
View
@@ -223,6 +223,11 @@ class object_base : public obj_base {
return 0;
}
virtual result_t onEventEmit(exlib::string ev)
{
return 0;
}
void extMemory(int32_t ext)
{
if (handle_.IsEmpty())
@@ -204,6 +204,8 @@ result_t object_base::_emit(exlib::string ev, Variant* args, int32_t argCount)
for (i = 0; i < m_args.size(); i++)
argv[i] = v8::Local<v8::Value>::New(m_obj->holder()->m_isolate, m_args[i]);
m_obj->onEventEmit(m_ev);
bool r;
JSTrigger(m_obj)._emit(m_ev, argv.data(), (int32_t)argv.size(), r);
@@ -225,9 +227,9 @@ result_t object_base::_emit(exlib::string ev, Variant* args, int32_t argCount)
return 0;
}
result_t object_base::emit(exlib::string ev, OptArgs args,
bool& retVal)
result_t object_base::emit(exlib::string ev, OptArgs args, bool& retVal)
{
onEventEmit(ev);
return JSTrigger(this).emit(ev, args, retVal);
}

0 comments on commit 3240d9d

Please sign in to comment.