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

fix(service-worker): listen for messages on the right event source #19954

Closed
wants to merge 1 commit into from

Conversation

@alxhub
Copy link
Contributor

commented Oct 26, 2017

Currently, the SwUpdate service doesn't receive messages from the SW.
This is because it attempts to subscribe to the 'message' event on
ServiceWorkerRegistration, when really messages are emitted by the
ServiceWorkerContainer.

This change moves to listening on ServiceWorkerContainer and changes
the mocks to reflect the way the browser actually works.

Currently, the SwUpdate service doesn't receive messages from the SW.
This is because it attempts to subscribe to the 'message' event on
ServiceWorkerRegistration, when really messages are emitted by the
ServiceWorkerContainer.

This change moves to listening on ServiceWorkerContainer and changes
the mocks to reflect the way the browser actually works.
@alxhub alxhub force-pushed the alxhub:fix-sw-comms branch from 0ec9209 to 6b65867 Oct 26, 2017
@mary-poppins

This comment has been minimized.

Copy link

commented Oct 26, 2017

@mary-poppins

This comment has been minimized.

Copy link

commented Oct 26, 2017

@@ -85,7 +85,7 @@ export function main() {
driver = new Driver(scope, scope, new CacheDatabase(scope, scope));

scope.clients.add('default');
scope.clients.getMock('default') !.queue.subscribe(msg => { reg.sendMessage(msg); });

This comment has been minimized.

Copy link
@gkalpak

gkalpak Oct 26, 2017

Member

I think you can remove reg and MockServiceWorkerRegistration from this file. It is not really used any more.

@@ -44,11 +44,9 @@ export function main() {
});
describe('SwPush', () => {
let push: SwPush;
let reg: MockServiceWorkerRegistration;

This comment has been minimized.

Copy link
@gkalpak

gkalpak Oct 26, 2017

Member

I think you can remove reg and MockServiceWorkerRegistration from this file. It is not really used any more.

@@ -36,6 +45,12 @@ export class MockServiceWorkerContainer {
get mockRegistration(): Promise<MockServiceWorkerRegistration> {

This comment has been minimized.

Copy link
@gkalpak

gkalpak Oct 26, 2017

Member

And I don't think you need this getter any more either 😃

matsko added a commit that referenced this pull request Oct 26, 2017
…19954)

Currently, the SwUpdate service doesn't receive messages from the SW.
This is because it attempts to subscribe to the 'message' event on
ServiceWorkerRegistration, when really messages are emitted by the
ServiceWorkerContainer.

This change moves to listening on ServiceWorkerContainer and changes
the mocks to reflect the way the browser actually works.

PR Close #19954
@matsko matsko closed this in 5adb7c9 Oct 26, 2017
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

commented Sep 12, 2019

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.