Use DOM Promises for MozLoopAPI functions where callbacks are currently used

RESOLVED WONTFIX

Status

Hello (Loop)
Client
P4
normal
RESOLVED WONTFIX
3 years ago
2 years ago

People

(Reporter: standard8, Unassigned)

Tracking

unspecified
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [tech-debt])

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
Created attachment 8450052 [details]
Example patch

We should use DOM promises for the MozLoopAPI functions which are currently based around callbacks.

The main functions to swap are currently ensureRegistered and hawkRequest.

Switching to use DOM promises isn't too difficult in itself (see example patch), the slightly more complicated bit is integrating into the Mocha & chai tests. There's information on that here:

For the records Mocha supports promises; quoting http://visionmedia.github.io/mocha/#asynchronous-code:

> Alternately, instead of using the done() callback, you can return a promise.

They also use https://github.com/domenic/chai-as-promised/ to extend the Chai expectation API.
(Reporter)

Comment 1

3 years ago
(In reply to Mark Banner (:standard8) from comment #0)
> They also use https://github.com/domenic/chai-as-promised/ to extend the
> Chai expectation API.

Additional xref http://chaijs.com/plugins/chai-as-promised
(Reporter)

Updated

3 years ago
Duplicate of this bug: 1044369
backlog: --- → -

Updated

2 years ago
backlog: - → tech-debt
Priority: -- → P4
Whiteboard: [tech-debt]
(Reporter)

Comment 3

2 years ago
I'm wontfixing this, as we're changing the MozLoopAPI due to e10s to use a message passing mechanism, and this is unlikely to fit with promises.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.