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

core(service-workers): sub-target message passing enabled. WIP #3555

Closed
wants to merge 3 commits into from

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented Oct 13, 2017

For early review. I have a bit more to do, but in case you're interested in big changes.. speak now. :)

fixes #709

this._parent = parentConnection;

this._parent.on('notification', this._onEvent.bind(this));
// now we repeat and do this again. we need to autoattach and grab a type: `worker` within
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I understood what's going on until I read this comment, isn't the attaching within happening in the onTargetAttached over in manager where you create manager in a manager?

this._sessionId = sessionId;
this._parent = parentConnection;

this._parent.on('notification', this._onEvent.bind(this));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my only gripe with the overall setup is this notification listener bit since it feels like a hacky way to override a method, can it not be done with regular override and super call?

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that the changes to driver are minimal, I've got plenty of naming 🚲 🏠 to do, but looks good for cleanup to me.

Only gripe is that hijacking of notification event to essentially do an override

let manager;
if (this._requiredType === 'service_worker') {
manager = new SWManager(session, {requiredType: 'worker'});
manager.listen();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my main question is if we could flatten this out and lose the recursive step.

If I'm reading/understanding this correctly (big if), it seems like it's always service_worker -> worker, and then the only thing the service_worker target is kept around (on the LH side) is for dispatching to the worker. Can we ditch a reference to the service_worker manager and instead listen for the follow up worker, and then only keep that around?

if (manager) return manager.sendCommandToSubTargets(method, params);
else return session.sendCommand(method, params);
});
return Promise.all(p).then(arr => _flatten(arr));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like this is set up to return an array of results...but what are all the results going to be coming from? Can we only attach to an active SW (so there should only be one)?

console.warn(`No subtargets yet for ${method}`);
}
// Some protocol domains are not supported by the dedicated worker but by the SW page
// Note: Log and Network are technically supported in both, but not completely,
Copy link
Collaborator

@wardpeet wardpeet Oct 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any documentation about this somewhere? Or just something you know?

@paulirish
Copy link
Member Author

Shelving this until the new target selection support is landed in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=775132

@paulirish paulirish closed this Oct 16, 2017
@paulirish paulirish deleted the swtarget branch March 2, 2018 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants