Re: [device-posture] Fetching the posture type needs to be async (#78)

Some other food for thought.

We may (or may not) see an OS API that will return the posture in a more synchronous manner say like the orientation of the device. In this case the browser do not derive the orientation using the accelerometer or gyro but just query the OS which has an always available orientation value (obviously using the same sensors but it's done in the background). As the posture will be determined using more than the hinge angle I'm hopeful that the OSes will support fetching the posture directly. Unfortunately I did not hear any official stance on that with Android, Windows 10 or even Windows 11. Even if such APIs were to be released we would be looking at 2022 at best (say Android 13 or a new version of Windows 11).

Now I personally think that `navigator.devicePosture.type` is more elegant than say `navigator.getDevicePosture()` (or whatever name) returning a Promise that would resolve when the posture is available. Also `navigator.devicePosture.type` will stay aligned with the orientation which is `window.screen.orientation.type`.

I'm personally not too concerned of the MQ triggering a relayout, if the OS APIs eventually land and browsers' implementation is updated, developers' code will work just fine and will not relayout anymore. However in the current state of affairs if we keep `navigator.devicePosture.type` we have to inform clearly that the posture may be determined asynchronously and developers must register to the change event. Again if the OS APIs were to land then the first call to navigator.devicePosture.type would work right away.
   

-- 
GitHub Notification of comment by darktears
Please view or discuss this issue at https://github.com/w3c/device-posture/issues/78#issuecomment-868516602 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 25 June 2021 13:54:25 UTC