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

navigator.getGamepads() should return a Promise #23

Closed
cvan opened this issue May 3, 2016 · 7 comments
Closed

navigator.getGamepads() should return a Promise #23

cvan opened this issue May 3, 2016 · 7 comments
Labels

Comments

@cvan
Copy link
Contributor

cvan commented May 3, 2016

Perhaps this is a dupe of #17, and perhaps this should first be discussed on the mailing list, but I think navigator.getGamepads() should return a Promise resolving an array of Gamepad objects (instead of returning the array, per the current spec + implementations).

@luser
Copy link
Contributor

luser commented Jun 21, 2016

I don't know how we could do this without breaking all the existing users of the API.

@danwdart
Copy link

Many devs use a different method, like pGetGamepads or getGamepadsP...
I suggest using a parameter? For instance getGamepads(true) will give you a promise and getGamepads(false) (default) won't?

@daoshengmu
Copy link
Collaborator

It might needn't. In FF, we just return the gamepads that already emit its first event, so it is not async behavior.

@GrosSacASac
Copy link

GrosSacASac commented Nov 28, 2017

you can always make a Promise on top off the events gamepadconnected

@cvan
Copy link
Contributor Author

cvan commented Nov 28, 2017

if we’re looking to make the Gamepad API safe for DOM contexts (which other issues cover), it probably makes sense to start thinking of creating a navigator.gamepads namespace.

similar thing happened for navigator.getUserMedia to navigator.mediaDevices.getUserMedia and navigator.getVRDisplays to navigator.vr.requestDevice.

this might warrant its own issue, but this is all could be handled by namespacing the API, moving the DOM events to emit on an EventTarget interface, and creating a Promise-based navigator.gamepads.get(…)

thoughts?

@sgraham sgraham added the v2 label Feb 14, 2018
@dgchrt
Copy link

dgchrt commented Feb 2, 2021

Currently navigator.getGamepads() returns an Object which already contains the up-to-the-minute status of gamepads. What would be the benefit of making this call asynchronous?

@marcoscaceres
Copy link
Member

marcoscaceres commented Aug 12, 2021

Going ahead and closing this, as it would break things.... The events at #152 should make the API better.

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

No branches or pull requests

8 participants