turn class into observer
This commit is contained in:
parent
3399480304
commit
bef4c84799
2 changed files with 6 additions and 1 deletions
|
@ -23,9 +23,13 @@ Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||||
: model_(new AtomMenuModel(this)),
|
: model_(new AtomMenuModel(this)),
|
||||||
parent_(nullptr) {
|
parent_(nullptr) {
|
||||||
InitWith(isolate, wrapper);
|
InitWith(isolate, wrapper);
|
||||||
|
model_->AddObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::~Menu() {
|
Menu::~Menu() {
|
||||||
|
if (model_) {
|
||||||
|
model_->RemoveObserver(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::AfterInit(v8::Isolate* isolate) {
|
void Menu::AfterInit(v8::Isolate* isolate) {
|
||||||
|
|
|
@ -18,7 +18,8 @@ namespace atom {
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
class Menu : public mate::TrackableObject<Menu>,
|
class Menu : public mate::TrackableObject<Menu>,
|
||||||
public AtomMenuModel::Delegate {
|
public AtomMenuModel::Delegate,
|
||||||
|
public AtomMenuModel::Observer {
|
||||||
public:
|
public:
|
||||||
static mate::WrappableBase* New(mate::Arguments* args);
|
static mate::WrappableBase* New(mate::Arguments* args);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue