Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.

Promises #10

Open
fesor opened this issue Oct 19, 2014 · 0 comments
Open

Promises #10

fesor opened this issue Oct 19, 2014 · 0 comments

Comments

@fesor
Copy link

fesor commented Oct 19, 2014

This will be much better to use promises in your library.

And instead of:

function success(fileUrl) {
    console.log('success: %s', fileUrl);
    mySuperCoolService(fileUrl).then(...);
}
function err(reason) {
    console.log('failed: %s', reason);
}

camera.takePicture(success, err);

user may use this:

camera.takePicture()
  .then(function (fileUri) {

     return mySuperCoolService(fileUrl)
  }, function (reason) {

     return $q.reject(reason);
  })
  .then(function (result) {
      return result; // some result processing...
  })
;

This is also solves issue that user should manually call $apply as you should do it from services.

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

No branches or pull requests

1 participant