Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Adds promise scan .done particularly to handle "No cameras" error #363

Merged
merged 3 commits into from
Nov 17, 2016
Merged

Adds promise scan .done particularly to handle "No cameras" error #363

merged 3 commits into from
Nov 17, 2016

Conversation

daserge
Copy link
Collaborator

@daserge daserge commented Nov 11, 2016

This fixes #361


// Timeout is needed so that the .done finalizer below has some time
// to be attached to the promise.
BarcodeReader.scanPromise = WinJS.Promise.timeout(200, WinJS.Promise.wrap(createPreview()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, why timeout is required, since composing a promise chain is sync, but perhaps this has something to do with sync createPreview being wrapped into promise. You might want to make createPreview return promise instead of this workaround.

Copy link
Collaborator Author

@daserge daserge Nov 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that WinJS.Promise.as and WinJS.Promise.wrap is sync so their contents are run before we get to the next statement - .done in our case, therefore the timeout() is required here to mark the promise contents as async.

@daserge
Copy link
Collaborator Author

daserge commented Nov 16, 2016

Addressed, thanks for review @vladimir-kotikov !

@vladimir-kotikov
Copy link
Collaborator

LGTM

@daserge daserge merged commit 68b6fd1 into phonegap:master Nov 17, 2016
@daserge daserge deleted the promise-done branch November 17, 2016 11:55
@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Example code on Win10 crashes app with hot-swappable camera hardware unplugged
2 participants