我的AlertService有
private subject = new Subject<Alert>();。我想在5秒钟后专心清除警报。我可以这样使用setTimeout():
autoClear(alertId?: string) {
setTimeout(
() => this.subject.next(new Alert({alertId})),
5000);
}
Run Code Online (Sandbox Code Playgroud)
我尝试使它更优雅,并创建了以下代码:
autoClear(alertId?: string) {
const delay = new Observable(x => {
x.next();
}).delay(5000).subscribe(() => {
this.subject.next(new Alert({alertId}));
delay.unsubscribe();
});
}
Run Code Online (Sandbox Code Playgroud)
这两个示例都可以工作,但看起来不像是使用RxJS的正确方法。我该如何改善?
我使用 Oracle SQL Developer 并且查询结果不会返回我的完整日期。在table -> data 中也有相同的格式 (yyyy/mm/dd) 。如何解决这个问题?我没有找到任何有帮助的选项。