本文整理匯總了TypeScript中rxjs/Rx.Observer.error方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observer.error方法的具體用法?TypeScript Observer.error怎麽用?TypeScript Observer.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rxjs/Rx.Observer
的用法示例。
在下文中一共展示了Observer.error方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
observer.next("test");
observer.complete();
} else {
observer.error(xhr.response);
}
}
};
示例2:
let obs: Observable<any> = Observable.create((observer: Observer<any>) => {
if (user.Email == "arun.thakur@mail.com" && user.Password == "123456") {
observer.next(true);
}
else {
observer.error("Invalid Credentials");
}
observer.complete();
//return () => { console.log("disposable called..."); }; //dispose observable
});
示例3: function
req.onload = function() {
if (req.status == 200) {
// If the status is 200, meaning there have been no problems,
// Yield the result to listeners and complete the sequence
observer.next(req.response);
observer.complete();
}
else {
// Otherwise, signal to listeners that there has been an error
observer.error(new Error(req.statusText));
}
};
示例4: Headers
return Observable.create((observer: Observer<any>) => {
if (this.authService.getToken() != null) {
let headers = new Headers();
headers.append('Authorization', `Bearer ${this.authService.getToken()}`);
if (!pullRequest.merge_commit) {
observer.error(new Error('Impossible to get PR diff from the API'));
observer.complete();
} else {
this.http.get(this.repoUrl + '/diff/' + pullRequest.merge_commit.hash, { headers: headers })
.subscribe(
(diffResponse: any) => {
observer.next(diffResponse._body);
observer.complete();
},
err => {
observer.error(err);
}
);
}
} else {
observer.error('no token');
}
});
示例5:
return Observable.create((observer: Observer<Coordinate>) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
position => {
const coordinate: Coordinate = {
latitude: position.coords.latitude,
longitude: position.coords.longitude
};
observer.next(coordinate);
observer.complete();
},
error => observer.error(error.message));
} else {
observer.error('Geolocation is not supported or is disabled on this device');
}
});
示例6: removeDomListener
}, error => {
observer.error(error);
removeDomListener();
observer.complete();
}, options);
示例7:
// On Error
(error: any) => {
console.log("Unable to execute request for additional remote resources")
results.error(error)
},