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

added Promise::delay and Promise::finally overload #2

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

prueckl
Copy link

@prueckl prueckl commented Oct 1, 2017

No description provided.

Thomas Prückl added 8 commits September 26, 2017 14:29
The 'this' may be destroyed at the time the lambda is executed.
consider the following async pseudo code:

---
try {
  await func1A();
  func1B();
} catch() {
  error1();
}

try {
  await func2A();
  func2B();
} catch() {
  error2();
}
---

transcompiled to Promise chain:

---
func1A.then([](){
  func1B();
})
.fail([](){
  error1();
})
.finally([](){
  return func2A();
})
.then([](){
  func2B();
)}
.fail([](){
  error2();
})
---
a previous promise has been rejected.

Example:
----------------
int result = 0;
try {
  result = await funcA();
} catch() {
  result = await funcB();
}

funcC(result);
----------------

Can be translated to:
---------------
funcA()
  .failCatch([](){
    return funcB();
  })
  .then([](int result){
    funcC(result);
  })
---------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant