diff --git a/README.md b/README.md index 8a77eae..bdfdcfc 100644 --- a/README.md +++ b/README.md @@ -653,7 +653,7 @@ void Example::init(Handle target) { Local ctor = Nan::GetFunction(proto).ToLocalChecked(); - _prototype.Reset(proto); + _constructor.Reset(ctor); Nan::Set(target, JS_STR("Example"), ctor); diff --git a/include/event-emitter.hpp b/include/event-emitter.hpp index 44361ac..d3fa83c 100644 --- a/include/event-emitter.hpp +++ b/include/event-emitter.hpp @@ -16,12 +16,13 @@ if (eventEmitter->_isDestroyed) return; +// This template class provides static-member initialization in-header template -struct StaticHolder { +class StaticHolder { +protected: static Nan::Persistent _prototype; static Nan::Persistent _constructor; }; - template Nan::Persistent StaticHolder::_prototype; template Nan::Persistent StaticHolder::_constructor; @@ -36,9 +37,9 @@ class EventEmitter : public StaticHolder, public Nan::ObjectWrap { typedef MAP_TYPE::iterator MAP_IT_TYPE; typedef FNMAP_TYPE::iterator FNMAP_IT_TYPE; -// Public V8 init public: + // Public V8 init static void init(v8::Local target) { v8::Local proto = Nan::New(newCtor);