久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='zQaXL'></tfoot>

  • <i id='zQaXL'><tr id='zQaXL'><dt id='zQaXL'><q id='zQaXL'><span id='zQaXL'><b id='zQaXL'><form id='zQaXL'><ins id='zQaXL'></ins><ul id='zQaXL'></ul><sub id='zQaXL'></sub></form><legend id='zQaXL'></legend><bdo id='zQaXL'><pre id='zQaXL'><center id='zQaXL'></center></pre></bdo></b><th id='zQaXL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zQaXL'><tfoot id='zQaXL'></tfoot><dl id='zQaXL'><fieldset id='zQaXL'></fieldset></dl></div>
    • <bdo id='zQaXL'></bdo><ul id='zQaXL'></ul>
  • <legend id='zQaXL'><style id='zQaXL'><dir id='zQaXL'><q id='zQaXL'></q></dir></style></legend>

    <small id='zQaXL'></small><noframes id='zQaXL'>

        以角度每 x 秒發出一次 http 請求

        http request every x seconds in angular(以角度每 x 秒發出一次 http 請求)

              <i id='WTRTc'><tr id='WTRTc'><dt id='WTRTc'><q id='WTRTc'><span id='WTRTc'><b id='WTRTc'><form id='WTRTc'><ins id='WTRTc'></ins><ul id='WTRTc'></ul><sub id='WTRTc'></sub></form><legend id='WTRTc'></legend><bdo id='WTRTc'><pre id='WTRTc'><center id='WTRTc'></center></pre></bdo></b><th id='WTRTc'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WTRTc'><tfoot id='WTRTc'></tfoot><dl id='WTRTc'><fieldset id='WTRTc'></fieldset></dl></div>

              1. <tfoot id='WTRTc'></tfoot>

                <small id='WTRTc'></small><noframes id='WTRTc'>

                  <tbody id='WTRTc'></tbody>

                  <bdo id='WTRTc'></bdo><ul id='WTRTc'></ul>
                • <legend id='WTRTc'><style id='WTRTc'><dir id='WTRTc'><q id='WTRTc'></q></dir></style></legend>
                • 本文介紹了以角度每 x 秒發出一次 http 請求的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試在 angular2 中每 x 秒刷新一次 http 調用.

                  I'm trying to refresh an http call every x seconds in angular2.

                    ionViewDidLoad() {
                  
                      let loader = this.LoadingController.create({
                        'content':'Please Wait'
                      });
                      loader.present().then(()=>{
                        this.http.request('http://mywebserver.com/apps/random.php').map(res=> res.json()).subscribe(data=>{
                          console.log(JSON.stringify(data));
                          loader.dismiss();
                          this.fact = data;
                        },err=>{
                          loader.dismiss();
                          let alert = this.alertCtrl.create({
                            title: 'Error!',
                            subTitle: 'Please check your Internet Connectivity',
                            buttons: ['OK']
                          });
                        alert.present();
                      })
                      })
                  
                    }
                  

                  我在頁面新加載時獲取數據.但現在我的問題是刷新 http 調用以每 x 秒獲取新數據

                  I get data when the page newly loads. But now my issue is refreshing the http call to get new data every x seconds

                  推薦答案

                  使用 Observable.interval:

                  import {Observable} from 'rxjs/Rx';
                  ...
                  constructor(...) {
                    Observable.interval(30000).subscribe(x => { // will execute every 30 seconds
                      this.ionViewDidLoad();
                    });
                  }
                  

                  或者在你的 ionViewDidLoad 函數中:

                  OR inside your ionViewDidLoad function:

                  Observable.interval(3000)
                            .timeInterval()
                            .flatMap(() => this.http.request('http://mywebserver.com/apps/random.php')
                            .map(res=> res.json())
                            .subscribe(data=>{
                                console.log(JSON.stringify(data));
                                loader.dismiss();
                                this.fact = data;
                              });
                  

                  編輯以回答您的評論.來自 Rxjs 文檔:

                  Edit to answer your comment. From the Rxjs docs:

                  timeInterval 運算符將源 Observable 轉換為Observable 發出指示之間經過的時間量的指示源 Observable 的連續發射.第一次發射從這個新的 Observable 中可以看出兩者之間經過的時間量觀察者訂閱 Observable 的時間和時間當源 Observable 發出它的第一項時.沒有相應的排放標記之間經過的時間量源 Observable 的最后一次發射和隨后的調用已完成.

                  The timeInterval operator converts a source Observable into an Observable that emits indications of the amount of time lapsed between consecutive emissions of the source Observable. The first emission from this new Observable indicates the amount of time lapsed between the time when the observer subscribed to the Observable and the time when the source Observable emitted its first item. There is no corresponding emission marking the amount of time lapsed between the last emission of the source Observable and the subsequent call to onCompleted.

                  timeInterval 默認操作超時Scheduler,但也有一個變體,允許您通過傳遞它來指定調度程序in 作為參數.

                  timeInterval by default operates on the timeout Scheduler, but also has a variant that allows you to specify the Scheduler by passing it in as a parameter.

                  在這種情況下,它基本上是 JavaScript 原生 setInterval() 函數的響應式/Rxjs 方式.

                  Basically in this case it would be the reactive/Rxjs way of JavaScript′s native setInterval() function.

                  這篇關于以角度每 x 秒發出一次 http 請求的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                  <i id='3PgaK'><tr id='3PgaK'><dt id='3PgaK'><q id='3PgaK'><span id='3PgaK'><b id='3PgaK'><form id='3PgaK'><ins id='3PgaK'></ins><ul id='3PgaK'></ul><sub id='3PgaK'></sub></form><legend id='3PgaK'></legend><bdo id='3PgaK'><pre id='3PgaK'><center id='3PgaK'></center></pre></bdo></b><th id='3PgaK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3PgaK'><tfoot id='3PgaK'></tfoot><dl id='3PgaK'><fieldset id='3PgaK'></fieldset></dl></div>

                  <small id='3PgaK'></small><noframes id='3PgaK'>

                    <tbody id='3PgaK'></tbody>

                        <bdo id='3PgaK'></bdo><ul id='3PgaK'></ul>

                        • <tfoot id='3PgaK'></tfoot>
                        • <legend id='3PgaK'><style id='3PgaK'><dir id='3PgaK'><q id='3PgaK'></q></dir></style></legend>

                            主站蜘蛛池模板: 欧美激情免费在线 | 国产黄a一级 | 久久久久久久久毛片 | 亚洲福利视频一区二区 | 成人免费一区二区 | 九九热在线免费视频 | 精品免费国产一区二区三区四区 | 99在线免费观看视频 | 性一交一乱一透一a级 | 久久免费精品 | 男女性毛片 | 成人黄色a| 中文字幕精品一区二区三区在线 | 福利视频网 | 国产精品1区 | 国产欧美视频一区 | 亚洲国产免费 | 日韩欧美一级片 | 亚洲天堂影院 | 精品综合在线 | 午夜精品网站 | 高清人人天天夜夜曰狠狠狠狠 | 免费在线观看av | 亚洲精品免费看 | 成人综合在线视频 | 国产精品激情小视频 | 欧美综合久久 | 国产精品一区在线 | 亚洲乱码国产乱码精品精的特点 | 国产成人久久 | 伊人久久在线观看 | 国产久 | 免费黄色在线 | 国产精品国产亚洲精品看不卡15 | 日日夜夜天天 | 蜜月aⅴ免费一区二区三区 99re在线视频 | 欧美一区二区 | 性一交一乱一透一a级 | 激情影院久久 | 久久久久亚洲精品 | 日韩欧美一级精品久久 |