close
Skip to content

Consider primary type plus options bag pattern in request methods #542

@ddorwin

Description

@ddorwin

XR.requestSession() and XRSession.requestReferenceSpace() both take a single options parameter. In many/most cases, only a single primary value from the options needs to be specified. It may be better to instead specify that primary value separately followed by an optional options parameter. This may both simplify the current API and allow for more flexibility for future extension.

Consider:

  • The pair of methods in the XR interface are intended to be used together but do not share parameter types:
    Promise<void> supportsSessionMode(XRSessionMode mode);
    Promise<XRSession> requestSession(optional XRSessionCreationOptions parameters);
  • XRReferenceSpaceOptions only contains a type and subtype.
  • IDL methods can accept different types in the same parameter slot (i.e., https://heycam.github.io/webidl/#idl-union). If the primary value is a separate parameter, subsequent parameters can be different types rather than needing to have a union of all possible values used for any primary mode/type.

With that in mind, the two methods might be changed as follows:

  • Promise<XRSession> requestSession(XRSessionMode mode, optional XRSessionCreationOptions options);
    • Note that one argument is now required. This is a minor part of the change, but it seems reasonable to expect the caller to specify the mode they want just as they do for supportsSessionMode().
  • Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type);

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed by pending PRA PR that is in review will resolve this issue.potential breaking changeIssues that may affect the core design structure.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions