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

Allow non-T3 components to listen for messages #43

Closed
nzakas opened this issue Apr 23, 2015 · 0 comments
Closed

Allow non-T3 components to listen for messages #43

nzakas opened this issue Apr 23, 2015 · 0 comments

Comments

@nzakas
Copy link
Contributor

nzakas commented Apr 23, 2015

Right now, when a message is broadcast(), only modules can listen for it. That works fine when you're dealing with just T3 components, but sometimes there are non-T3 components that need to be informed of messages as well.

We can implement this quite simply by firing a message event when broadcast() is called. This would allow non-T3 components to do the following:

Box.Application.on('message', function(event) {

    if (event.data.message === 'some_specific_message') {
        // do something
    }

});

So event.data.message is the message name and event.data.messageData is whatever would be passed in as the second argument to onmessage in a module.

@nzakas nzakas closed this as completed in 598744a Apr 23, 2015
nzakas added a commit that referenced this issue Apr 23, 2015
Update: Fire event when broadcast() is called (fixes #43)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant