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

Use an interface for ContactInfo & set unrequested fields to null. #23

Closed
wants to merge 2 commits into from

Conversation

rayankans
Copy link
Collaborator

Using an interface would help with issue #19, since we would be able to check if a certain property is supported by the browser. It was also the result of some conversation in #21

@beverloo
Copy link
Member

beverloo commented Aug 9, 2019

I like that this enables per-property feature detection.

With the default serializer behaviour, the following would happen:

const data = await navigator.contacts.select(['tel']);
console.log(JSON.stringify(data));
[
  {
    "email": null,
    "name": null,
    "tel": ["+442079460789"]
  }
]

That seems rather wasteful, particularly when multiple contacts are being selected, or when more fields may be added to the API. Would it be fair to teach a new ContactInfo about the properties passed to the select() call? It feels a bit hackish.

@domenic wdyt, given that you suggested moving to dictionaries in #5?

@domenic
Copy link

domenic commented Aug 9, 2019

I still believe that for data that does not have behavior (e.g. methods), a dictionary should be strongly preferred. I do not support moving in this direction.

@yoavweiss
Copy link
Collaborator

@rayankans - Can you join the WICG in order to appease the IPR bots?

@rayankans
Copy link
Collaborator Author

We could potentially have use a non-default toJSON implementation that ignores null values, but yeah using a dict seems cleaner at this point.

@rayankans rayankans closed this Aug 13, 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.

4 participants