feat(buffer): buffer messages before devTools open
Before the devTools are opened, messages should be buffered. This way they can be delivered when the devTools are opened.
This commit is contained in:
parent
e1cd70d98e
commit
d0da55123f
@ -1,6 +1,13 @@
|
||||
|
||||
var buffer = [];
|
||||
function addToBuffer(message) {
|
||||
buffer.push(message);
|
||||
}
|
||||
chrome.runtime.onMessage.addListener(addToBuffer);
|
||||
chrome.runtime.onConnect.addListener(function(port) {
|
||||
|
||||
chrome.runtime.onMessage.removeListener(addToBuffer);
|
||||
buffer.forEach(function(msg) {
|
||||
port.postMessage(msg);
|
||||
});
|
||||
// context script –> background
|
||||
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
|
||||
port.postMessage(msg);
|
||||
|
Reference in New Issue
Block a user