Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Compound Events #4

Open
jiggliemon opened this issue Feb 25, 2012 · 4 comments
Open

Create Compound Events #4

jiggliemon opened this issue Feb 25, 2012 · 4 comments
Labels

Comments

@jiggliemon
Copy link
Collaborator

A way to call an event that consists of >=2 events.

this.addEvent(['template.loaded','model.data.loaded'], this.compileTemplate);
@GCheung55
Copy link
Owner

Per conversation with @jiggliemon, it's the execution of this.compileTemplate once template.loaded and model.data.loaded are fired/triggered.

Right, @jiggliemon?

@GCheung55 GCheung55 reopened this Feb 25, 2012
@jiggliemon
Copy link
Collaborator Author

Right.
I've been back and fourth on how to (if at all) handle this for non-latched events.

For instance, and sake of argument, you'll only load both a template and model data once. Thereby determining that once each has fired once, you can safely fire the Compound event.

Another example where an App depends on having the Async loading "FB" object available:

window.addEventListener('DOMContentLoaded', function() {
  fireEvent('DOM:Ready');
});

fbAsyncInit = function() { 
  fireEvent('FB:Ready') 
};
// with optional second string argument to make 
// for easier accessibility?
addEvent(['DOM:Ready','FB:Ready'], 'APP:Ready');

APP = {
  init: function () {
    addEvent('APP:Ready', function() {
      FB.api('/me', function (response) {
        $('name').set('text', response.name);
      })
    });
  }
}

Notice how the APP#init method has a dependency on both the FB object and DOM to be available.

@jiggliemon
Copy link
Collaborator Author

I made a quick example here using switches.
http://jsfiddle.net/jiggliemon/FwBgf/

However im still not sure this is the best way to go.

@jiggliemon
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants