저는 현재 Angular 2 내에서 사용되는 내 자신의 Promise를 구현하려고 노력 하고 있습니다. 약속이 맞으면 거부 될 첫 번째 Promise에서만 reject
받을 Error: Uncaught (in promise): nope(…)
수 있습니다.
그것은이다 Angular 2.0.0-rc.4
,하지만 난 다른 행동이 나타났습니다. 내 질문은 이것이 약속에 대한 이해의 오류입니까, 아니면 Angular 프로젝트에보고해야하는 버그입니까?
샘플 코드 :
import {Component} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic'
@Component({
template: "TestComponent"
})
class TestComponent {
}
bootstrap(TestComponent, []);
let p = new Promise((resolve, reject) => {
console.log("create promise");
reject("nope");
});
console.log("setting up");
p.then(r => console.log("then: " + r));
p.catch(e => console.log("reject: " + e));
console.log("setup done");
콘솔 (Google Chrome 51.0.2704.106, Linux 64 비트) :
create promise
setting up
setup done
reject: nope
Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
Unhandled Promise rejection: nope ; Zone: <root> ; Task: Promise.then ; Value: nope
Error: Uncaught (in promise): nope(…)
그것은해야한다
p
.then(r => console.log("then: " + r))
.catch(e => console.log("reject: " + e));
p.then(...)
혼자서 처리되지 않은 체인을 생성하면 Zone.js가 귀찮습니다. Bluebird의 '처리되지 않은 거부'를 처리했다면 이미 규칙을 알고있을 것입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다