refactor: ginify Tray (#22822)

* refactor: ginify Tray

* lint

* improve argument parsing logic

* remove redundant imports from tray.js

* new Tray produces an instanceof Tray

* make Constructible generic

* lint

* clean up on exit
This commit is contained in:
Jeremy Apthorp 2020-03-29 18:32:02 -07:00 committed by GitHub
parent 76ae3b7ecb
commit a3e28788ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 380 additions and 88 deletions

View file

@ -33,6 +33,21 @@ class EventEmitterMixin {
std::forward<Args>(args)...);
}
// this.emit(name, event, args...);
template <typename... Args>
bool EmitCustomEvent(base::StringPiece name,
v8::Local<v8::Object> custom_event,
Args&&... args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Object> wrapper;
if (!static_cast<T*>(this)->GetWrapper(isolate).ToLocal(&wrapper))
return false;
v8::Local<v8::Object> event =
internal::CreateEvent(isolate, wrapper, custom_event);
return EmitWithEvent(isolate, wrapper, name, event,
std::forward<Args>(args)...);
}
protected:
EventEmitterMixin() = default;