本文整理汇总了TypeScript中rxjs/Observer.Observer.complete方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observer.complete方法的具体用法?TypeScript Observer.complete怎么用?TypeScript Observer.complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Observer.Observer
的用法示例。
在下文中一共展示了Observer.complete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ExecutionCompletedAction
process.on("exit", (code: number, sig) => {
processStillRunning = false;
/** Successful completion if exit code is 0 */
const isCompleted = code === 0;
/**
* Killing a process manually will throw either exitCode 143, or
* a SIGINT/SIGTERM/SIGKILL in different circumstances, so we check for both
* */
const isCancelled = code === 143 || sig;
if (isCompleted) {
this.store.dispatch(new ExecutionCompletedAction(appID));
obs.complete();
return;
} else if (isCancelled) {
/**
* Cancellation is initially triggered from unsubscribing from killing the process
* when unsubscribing from the observable.
* ExecutionStopAction is therefore dispatched from the original place.
* @see executionUnsubscribe
*/
obs.complete();
return;
} else {
this.store.dispatch(new ExecutionErrorAction(appID, new ExecutionError(code)));
obs.error(new Error(`Execution failed with exit code ${code}.`));
}
});
示例2: isPresent
let onLoad = () => {
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
// response/responseType properties were introduced in XHR Level2 spec (supported by
// IE10)
let body = isPresent(_xhr.response) ? _xhr.response : _xhr.responseText;
let headers = Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders());
let url = getResponseURL(_xhr);
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
let status: number = _xhr.status === 1223 ? 204 : _xhr.status;
// fix status code when it is 0 (0 status is undocumented).
// Occurs when accessing file resources or on Android 4.1 stock browser
// while retrieving files from application cache.
if (status === 0) {
status = body ? 200 : 0;
}
var responseOptions = new ResponseOptions({body, status, headers, url});
if (isPresent(baseResponseOptions)) {
responseOptions = baseResponseOptions.merge(responseOptions);
}
let response = new Response(responseOptions);
if (isSuccess(status)) {
responseObserver.next(response);
// TODO(gdi2290): defer complete if array buffer until done
responseObserver.complete();
return;
}
responseObserver.error(response);
};
示例3:
return Observable.create((observer:Observer<any>) => {
debugger;
observer.next([
{id: 1, contentMarkdown: 'abc', contentRendered: 'abc', title: 'demo'}
]);
observer.complete();
});
示例4: catchResponse
catchResponse(res:Response,observer:Observer<Response>):void {
if(res.status === 403) {
console.log('Unauthorized request:',res.text());
this.accountEventsService.logout({error:res.text()});
}
observer.complete();
}
示例5: return
return new Observable<T>((observer: Observer<T>) => {
observers.push(observer);
values.forEach((value: T) => {
observer.next(value);
});
if (completed) {
observer.complete();
}
if (!subscription) {
subscription = this.subscribe(
sendNext,
sendError,
sendComplete
);
}
return () => {
const i = observers.indexOf(observer);
if (i !== -1) {
observers.splice(i, 1);
}
if (observers.length === 0 && subscription) {
subscription.unsubscribe();
}
};
});
示例6:
(results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => {
if (status === google.maps.GeocoderStatus.OK) {
observer.next(results[0].formatted_address);
observer.complete();
} else {
observer.error(status);
}
}
示例7:
const onComplete = () => {
if (savedError !== null) {
observer.error(savedError);
} else {
observer.next(savedResult);
observer.complete();
}
};
示例8:
(results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => {
if (status === google.maps.GeocoderStatus.OK) {
observer.next(results);
observer.complete();
} else {
console.log('Geocoding service: geocoder failed due to: ' + status);
observer.error(status);
}
})
示例9: function
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
if (xhr.status >= 200 && xhr.status < 300) {
thatObserver.next(xhr.responseText);
thatObserver.complete();
} else {
thatObserver.error(xhr.responseText);
}
}
};
示例10: ExecutionStoppedAction
const cleanup = () => {
if (processStillRunning) {
this.store.dispatch(new ExecutionStoppedAction(appID));
}
if (execution) {
execution.kill();
}
obs.complete();
};