久久久久久久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>

                            主站蜘蛛池模板: 日韩精品三区 | 超碰人人人 | 色播av| 欧美成人a∨高清免费观看 91伊人 | 91美女视频| 免费观看av网站 | av黄色在线 | 成人免费观看男女羞羞视频 | 久色一区 | 亚洲一区二区免费 | 国产精品免费一区二区 | 亚洲精品免费视频 | 日韩和的一区二在线 | 亚洲欧美一区二区三区情侣bbw | 91人人看 | 国产在线精品一区二区 | 日本免费在线观看视频 | 天天爱爱网 | 精品国产一区一区二区三亚瑟 | 在线观看成人 | 欧美不卡在线 | 羞羞视频在线观看网站 | 乱一性一乱一交一视频a∨ 色爱av | 成年人网站在线观看视频 | 成人精品一区 | 免费视频二区 | 日韩伦理电影免费在线观看 | 久久久av| 国产成人一区二区三区久久久 | 国产一级视频在线观看 | 性一爱一乱一交一视频 | 色资源在线 | 另类专区亚洲 | 日韩在线观看视频一区 | 日韩av啪啪网站大全免费观看 | 丁香久久 | www.久久久.com | www四虎影视 | 日本大片在线播放 | 中文字幕视频三区 | 91精品国产综合久久精品 |