Skip to content

Conversation

@FabioPinheiro
Copy link
Contributor

Update PushSubscription to better reflect w3 standards:
-Change the return type of method toJSON
-Add missing properties (expirationTime, options)

Disclosure I have no idea what I'm doing here or if this is event a problem for anyone else.
(The impression that I have is that if any one is calling this method this will throw a cast extension)

This PR fix my problem but I don't know if this js.Dictionary[js.Any] is the right type, and maybe could be better refine. (https://www.w3.org/TR/2018/WD-push-api-20181026/#idl-def-pushsubscriptionoptionsinit)

@FabioPinheiro
Copy link
Contributor Author

Fix proposal for #346

*
* MDN
*/
val expirationTime: Double = js.native
Copy link
Member

Choose a reason for hiding this comment

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

This should be a java.lang.Double so that null is an acceptable value.

* MDN
*/
def toJSON(): String = js.native
def toJSON(): js.Dictionary[js.Any] = js.native
Copy link
Member

Choose a reason for hiding this comment

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

You should use a new type PushSubscriptionJSON as specified at https://www.w3.org/TR/2018/WD-push-api-20181026/#pushsubscription-interface. Something like:

trait PushSubscriptionJSON extends js.Object {
  val endpoint: String
  val expirationTime: java.lang.Double
  val keys: js.Dictionary[String]
}

Update PushSubscription to better reflect w3 standards:
-Change the return type of method toJSON
-Add missing properties (expirationTime, options)
@FabioPinheiro FabioPinheiro force-pushed the master branch 2 times, most recently from b3cd82b to b488d71 Compare March 5, 2019 00:53
Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

Thank you!

@sjrd sjrd changed the title Fix PushSubscription.toJSON was the wrong return type (#346) Fix #346: Give the correct type to PushSubscription.toJSON Mar 5, 2019
@sjrd sjrd merged commit 52ebfcc into scala-js:master Mar 5, 2019
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 this pull request may close these issues.

2 participants