Skip to content

Commit

Permalink
events, refactor: save the wrapper function into data object to avoid…
Browse files Browse the repository at this point in the history
… using Callee.
  • Loading branch information
xicilion committed Nov 2, 2017
1 parent d860ada commit f551793
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fibjs/include/Trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class JSTrigger {

v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(_data->Get(isolate->NewString("_func")));
v8::Local<v8::Value> v = _data->Get(isolate->NewString("_ev"));
v8::Local<v8::Function> _wrap = v8::Local<v8::Function>::Cast(_data->Get(isolate->NewString("_wrap")));

exlib::string ev;
GetArgumentValue(v, ev, true);
Expand All @@ -241,7 +242,7 @@ class JSTrigger {

v8::Local<v8::Object> vr;
JSTrigger t(args);
t.off(ev, args.Callee(), vr);
t.off(ev, _wrap, vr);

func->Call(args.This(), (int32_t)_args.size(), _args.data());
}
Expand All @@ -255,6 +256,8 @@ class JSTrigger {

v8::Local<v8::Function> wrap = _isolate->NewFunction("_onceWrap", _onceWrap, _data);
wrap->Set(NewString("_func"), func);
_data->Set(NewString("_wrap"), wrap);

putFunction(GetHiddenList(ev, true), wrap, ev);

retVal = o;
Expand Down

0 comments on commit f551793

Please sign in to comment.