Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Introduce `module.root` #44

Open
wilsonpage opened this Issue · 3 comments

2 participants

@wilsonpage

I'm proposing we set a new reference on each module with a view, this would be referred to as root. this.root would refer to the outermost module in the view hierarchy.

This seems like a simple thing, but opens up a whole host of communication options. Modules are now able to listen to events that happen on the root module (the single point of contact with our app).

this.root.on('themechange', function(type) {
  this.classList.remove(this.theme);
  this.classList.add(this.theme = type);
});

then...

view.fire('themechange', 'dark');

More controversially this could be used to set a single shared models across multiple modules, if need be.

@matthew-andrews

+1

@wilsonpage

@matthew-andrews highlighted a concern that bubbling events could mean module event firing may cause strange 'rebounding' from the root node,

@matthew-andrews

We have found ourselves in need for this after all :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.