本文整理汇总了TypeScript中rxjs/Rx.Observable.timer方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.timer方法的具体用法?TypeScript Observable.timer怎么用?TypeScript Observable.timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Rx.Observable
的用法示例。
在下文中一共展示了Observable.timer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: detail
private detail(modal,area){
modal.open();
Observable.timer(500).subscribe(()=>{
area.focus();
area.select();
});
}
示例2: runPreIFrameTasks
runPreIFrameTasks() {
if (this._preIFrameTasks && this._preIFrameTasks.isUnsubscribed) {
this._preIFrameTasks.unsubscribe();
}
this._preIFrameTasks = Observable.timer(0, 60000)
.concatMap<string>(() => this._http.get('api/token?plaintext=true').retry(5).map<string>(r => r.text()))
.subscribe(t => this._userService.setToken(t));
}
示例3:
.debounce(doc => {
if (doc.uri !== lastValidated && lastDurationSelector) {
lastDurationSelector.next(0);
}
lastDurationSelector = new Rx.Subject<number>();
Rx.Observable.timer(activeSettings.spellCheckDelayMs || defaultDebounce).subscribe(lastDurationSelector);
return lastDurationSelector;
})
示例4: pollForActiveVdb
/**
* Polls the server for the specified VDB. Polling will terminate if
* (1) The VDB is active
* (2) The VDB is in a failed state
* (3) The polling duration has lapsed
* @param {string} vdbName the name of the VDB
* @param {number} pollDurationSec the duration (sec) to poll the server
* @param {number} pollIntervalSec the interval (sec) between polling attempts
*/
public pollForActiveVdb(vdbName: string, pollDurationSec: number, pollIntervalSec: number): void {
const pollIntervalMillis = pollIntervalSec * 1000;
const pollIterations = pollDurationSec / pollIntervalSec;
let pollCount = 0;
const self = this;
// start a timer after one second
const timer = Observable.timer(1000, pollIntervalMillis);
this.deploymentSubscription = timer.subscribe((t: any) => {
this.getTeiidVdbStatuses()
.subscribe(
(resp) => {
for ( const vdbStatus of resp ) {
if ( vdbStatus.getName() !== vdbName ) {
continue;
}
if ( vdbStatus.isActive() ) {
this.notifierService.sendVdbDeploymentStatus(vdbStatus);
self.deploymentSubscription.unsubscribe();
} else if ( vdbStatus.isFailed() ) {
this.notifierService.sendVdbDeploymentStatus(vdbStatus);
self.deploymentSubscription.unsubscribe();
}
}
pollCount++;
if (pollCount > pollIterations) {
// Timed out status
const status: VdbStatus = new VdbStatus();
status.setName(vdbName);
status.setActive(false);
status.setLoading(false);
status.setFailed(true);
const errors: string[] = [];
errors.push("Deployment polling timed out");
status.setErrors(errors);
// broadcast the status
this.notifierService.sendVdbDeploymentStatus(status);
self.deploymentSubscription.unsubscribe();
}
},
(error) => {
// Error status
const status: VdbStatus = new VdbStatus();
status.setName(vdbName);
status.setActive(false);
status.setLoading(false);
status.setFailed(true);
const errors: string[] = [];
errors.push("Deployment failed");
status.setErrors(errors);
// Broadcast the status
this.notifierService.sendVdbDeploymentStatus(status);
self.deploymentSubscription.unsubscribe();
}
);
});
}
示例5: ngOnInit
ngOnInit() {
this.generateData();
let timer = Observable.timer(5000, 2000);
this.subscription = timer.subscribe(t => {
if (!this.updateData()){
this.subscription.unsubscribe();
}
});
}
示例6: ngOnInit
ngOnInit() {
this.breakLen = 10;
this.sessionLen = 25;
this.timeRemaining = this.sessionLen * 60;
let timer = Observable.timer(0,1000);
timer.subscribe(t => this.update());
this.synth = new SynthSimple(new AudioContext());
this.isSoundingAlarm = false;
}
示例7: scheduleViewUpdate
/**
* We have to poll the upload progress, because flow.js doesn't send events about it.
*
* Schedule a next view update after a second as long as flow.js has files.
*/
scheduleViewUpdate(changeDetectorRef: ChangeDetectorRef, flow: any) {
console.log("scheduling view update");
Observable.timer(1000).subscribe(() => {
// TODO check if view not destroyed
changeDetectorRef.detectChanges();
if (flow.files.length > 0) {
this.scheduleViewUpdate(changeDetectorRef, flow);
}
});
}
示例8: getJson
getJson(url: string, update: number) {
console.log(`reading ${ url }`);
if (update !== -1) {
return Observable.timer(0, update)
.flatMap(() => this.http.get(url))
.map(response => response.json());
} else {
return this.http.get(url)
.map(response => response.json());
}
}
示例9: init
public init(hour, minute) {
this.normal = true;
this.warning = false;
this.alarm = false;
this.currentTime = new Date();
this.alarmTime = this.setAlarmTime(hour, minute);
this.timer = Observable.timer(0,1000);
let onTimerTick = this.timer.subscribe(x => {
this.currentTime = new Date();
this.checkAlarmTime();
});
}
示例10: runClock
runClock(){
if(this.host==true){
let timer = Observable.timer(0,1000);
this.timerSubscription = timer.subscribe(t=>{
if(t <= this.gameClock.duration){
this.gameClock.ticks = t;
this.firebaseServer.update({Timer:this.gameClock.duration-this.gameClock.ticks});
} else {
this.stopClock();
}
})
}
}