-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix dropping first message by queueing messages before store is wrapped
wrapStore is no longer directly exported, it's constructed by createWrapStore. createWrapStore must be called synchronously when the service worker starts, allowing any message events to be queued and processed later after wrapStore is called. This avoids dropping dispatches from extension contexts that wake the service worker with a message.
- Loading branch information
1 parent
2ff04a0
commit bf485ad
Showing
5 changed files
with
235 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import Store from './store/Store'; | ||
import applyMiddleware from './store/applyMiddleware'; | ||
import wrapStore from './wrap-store/wrapStore'; | ||
import alias from './alias/alias'; | ||
import Store from "./store/Store"; | ||
import applyMiddleware from "./store/applyMiddleware"; | ||
import createWrapStore from "./wrap-store/wrapStore"; | ||
import alias from "./alias/alias"; | ||
|
||
export {Store, applyMiddleware, wrapStore, alias}; | ||
export { Store, applyMiddleware, createWrapStore, alias }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const createDeferredListener = () => { | ||
let resolve = () => {}; | ||
const fnPromise = new Promise((resolve_) => (resolve = resolve_)); | ||
|
||
const listener = (message, sender, sendResponse) => { | ||
fnPromise.then((fn) => { | ||
fn(message, sender, sendResponse); | ||
}); | ||
|
||
// Allow response to be async | ||
return true; | ||
}; | ||
|
||
return { setListener: resolve, listener }; | ||
}; |
Oops, something went wrong.