Closed
Bug 884136
Opened 11 years ago
Closed 11 years ago
messages should be queued until the first listener is attached
Categories
(Add-on SDK Graveyard :: General, defect)
Add-on SDK Graveyard
General
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: evold, Unassigned)
References
Details
If I have a Sidebar/Panel/Widget thing that adds a `addon` global to the associated window, then it will be impossible to listen to the following 'X' message using the `addon` global.
In Addon:
thing.once('attach', function(worker) {
worker.port.emit('X', 'Y');
});
In Content:
<script>
addon.on('X', function doStuff() {})
</script>
IE `doStuff` above is never called.
The only way this message passing is possible is to have the window use the `addon` to initiate the communication, or wait until the window is loaded before emit messages to the worker.
At the moment the best solution I can think of is to queue these messages and emit them when the first available listener is attached.
This doesn't seem ideal tho..
Reporter | ||
Comment 1•11 years ago
|
||
The example on https://github.com/mozilla/addon-sdk/wiki/JEP-Sidebars is a good example of what does not work, the same is true for panels.
Reporter | ||
Comment 2•11 years ago
|
||
I just want to see what you think Irakli, before I attempt to patch this.
Flags: needinfo?(rFobic)
Comment 3•11 years ago
|
||
Erik I'm not convinced that queuing up messages by default is a good idea, it may make sense for that specific cases, but there maybe be others when it wouldn't. I think it would make more sense to expose something like `thing.on("ready", function(port) { ... })` instead or make a helper function like `enqueue(thing, "X", "Y")` that will queue up messages.
Flags: needinfo?(rFobic)
Updated•11 years ago
|
Flags: needinfo?(evold)
Reporter | ||
Comment 4•11 years ago
|
||
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] [@gozala] from comment #3)
> `thing.on("ready", function(port) { ... })` instead or make a helper
> function like `enqueue(thing, "X", "Y")` that will queue up messages.
I like both of these ideas, for now I think I will former, by emitting the `show` event when the sidebar loads instead of when it starts showing.
Atm my ui-sidebar branch emits `attach` when the window is created, before `show` which emits when the window loads.
sidebar.on('attach', function(worker) {});
sidebar.on('show', function({worker}) {});
So I think we can close this for now. No matter when show emits we should be able to pass a worker.
Flags: needinfo?(evold)
Comment 5•11 years ago
|
||
Closing per the last comment.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•