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

Define a serializer for PushSubscription #125

Closed
beverloo opened this issue Mar 17, 2015 · 6 comments · Fixed by #140
Closed

Define a serializer for PushSubscription #125

beverloo opened this issue Mar 17, 2015 · 6 comments · Fixed by #140

Comments

@beverloo
Copy link
Member

Given this snippet:

swRegistration.pushManager.subscribe().then(function (subscription) {
  var x = JSON.stringify(subscription);
});

What is x meant to be? Today it's "{}" because attributes on an interface don't get serialized by default. This makes sense for DOM objects, but much less so for POD-like structures like this.

Since it's likely that developers will want to send all data to their application server, we should define a serializer for the interface.

I believe we can do this as follows:

interface PushSubscription {
  ...
  serializer = { endpoint, subscriptionId };
}
@martinthomson
Copy link
Member

SGTM, minus the actual fields, over which I think we need to continue discussion.

@beverloo
Copy link
Member Author

This is of course orthogonal to the actual fields, which is tracked in #56.

@bzbarsky
Copy link

@beverloo Why not just use serializer = { attributes };?

@beverloo
Copy link
Member Author

@bzbarsky Even better, thanks for the suggestion!

@martinthomson
Copy link
Member

As I've proposed in #130, one of the attributes would be an ArrayBuffer, which is not supported in the declarative syntax for serializers. That means we'd need prose for the serializer behaviour (sadly).

@owencm
Copy link

owencm commented Mar 27, 2015

FWIW, I strongly support the proposal to define sensible JSON serialization for subscription - the fact that we no longer do this broke a very reasonable flow, causing me to do:

subscription = {endpoint: subscription.endpoint, subscriptionId: subscription.subscriptionId}

which is pretty gross imho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants