当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript FirebaseObjectObservable.subscribe方法代码示例

本文整理汇总了TypeScript中angularfire2.FirebaseObjectObservable.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FirebaseObjectObservable.subscribe方法的具体用法?TypeScript FirebaseObjectObservable.subscribe怎么用?TypeScript FirebaseObjectObservable.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angularfire2.FirebaseObjectObservable的用法示例。


在下文中一共展示了FirebaseObjectObservable.subscribe方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

  constructor(public platform: Platform, public navCtrl: NavController, public user:User, public push: Push, public navParams: NavParams, storage: Storage, public af: AngularFire, public loadingCtrl:LoadingController) {



  	// CARICA TUTTE LE GARE NEL DATABASE
    let loader = this.loadingCtrl.create({
    content: "Attendere il caricamento delle gare..."
    });
    loader.present();
    this.gare = af.database.object('/gare', { preserveSnapshot: true  });
    this.gare.subscribe(snapshot => {
        storage.set('gareDB', snapshot.val());
        this.navCtrl.setRoot(Page1)
        
    });
    this.gare.subscribe(() => loader.dismissAll());

    if (this.platform.is('android')) {  
      this.push.register().then((t: PushToken) => {
         return this.push.saveToken(t);
      }).then((t: PushToken) => {
         this.notificheSnap = this.af.database.object('/utenti/'+this.user.id+'/notifiche/', { preserveSnapshot: true });
         this.notificheSnap.set({pushToken:t.token});
      });
    }

    
  }
开发者ID:gianmichelesiano,项目名称:Bandigare,代码行数:28,代码来源:aggiorna.ts

示例2: exportCSV

 exportCSV() {
   var dataString = "heyjoheyjoheyjoheyjo";
   var data = [];
   var filename = "";
   this.poll.subscribe((snap: any) => {
     if (snap.options !== undefined) {
       filename = snap.name.split(' ').join('') + ".results";
       for (let obj of snap.options) {
         data.push([obj.value, obj.score]);
       }
       data.push(['Total', this.total]);
     }
   });
   var csvContent = "data:text/csv;charset=utf-8,";
   data.forEach(function(infoArray, index){
     dataString = infoArray.join(",");
     csvContent += index < data.length ? dataString+ "\n" : dataString;
   });
   var encodedUri = encodeURI(csvContent);
   var link = document.createElement("a");
   link.setAttribute("href", encodedUri);
   link.setAttribute("download", filename+".csv");
   document.body.appendChild(link); // Required for FF
   link.click(); // This will download the data file named "my_data.csv".
 }
开发者ID:raayanpillai,项目名称:droppoll-beta,代码行数:25,代码来源:poll-result-view.component.ts

示例3: constructor

 constructor(af:AngularFire, renderer: Renderer){
   this.URL = window.location.href;
   this.onOff = af.database.object('/'+this.URL.split('/game/')[1]+'/Globals/OnOff',{preserveSnapshot:true});
   this.onOff.subscribe(snapshot =>{
     this.environmentSnapshot = snapshot.val();
   });
   this.environment = af.database.object('/'+this.URL.split('/game/')[1]+'/Globals/Environment');
   this.players = af.database.object('/'+this.URL.split('/game/')[1]+'/Players',{preserveSnapshot:true});
   this.players.subscribe(snapshot =>{
     this.playersSnapshot = snapshot.val();
   });
   /* Gets keyup */
   this.getKey = renderer.listenGlobal('document', 'keyup', (event) => {
     var key = event.keyCode;
     this.toggleBtn(key);
   });
 }
开发者ID:JacobDeming,项目名称:HotfixEngine,代码行数:17,代码来源:environment.component.ts

示例4:

    let sub = this.route.params.subscribe(params => {
      this.uid = params['id']; // (+) converts string 'id' to a number
      this.user = this.af.database.object('users/' + this.uid);
      this.user.subscribe(user => {

        if (user) this.u = user;
        console.log(JSON.stringify(user));
      });
    });
开发者ID:mierze,项目名称:grouple-ng2,代码行数:9,代码来源:user-edit.ts

示例5: Observable

 return new Observable(observer => {
     this._profile.subscribe(data => {
         if (!data.hasOwnProperty('$value')) {
             observer.next(data);
         } else {
             observer.error("No profile found!");
         }
     });
 });
开发者ID:marcelpetersen,项目名称:life-guide-hybrid,代码行数:9,代码来源:profile.service.ts

示例6:

        this.routeParams = this.route.params.subscribe(params => {
            let id = params['id'];
            if (id) {
                this.stock = this.stockService.getStockExchange(id);
                this.stock.subscribe((stock: StockExchange) => {
                    this.titleService.setTitle(stock.name)
                });
            }

        });
开发者ID:JacekKosciesza,项目名称:InvestSystemsOrg,代码行数:10,代码来源:stock-detail.component.ts

示例7: constructor

 constructor(af:AngularFire){
   this.URL = window.location.href;
   this.timerObservable = af.database.object('/'+this.URL.split('/game/')[1]+'/Timer',{preserveSnapshot:true});
   this.timerObservable.subscribe(snap =>{
     if (snap.val()==0) {
       this.animate(this.class,this.action);
     } else {
       this.animateStance(this.class);
     }
   })
   this.playerObservable = af.database.object('/'+this.URL.split('/game/')[1]+'/Players/player2',{preserveSnapshot:true});
   this.playerObservable.subscribe(snap =>{
     this.action=snap.val().action;
     this.class=snap.val().playerClass;
     /* check if still alive */
     if (snap.val().currentHitpoints < 0) {
       this.animateDefeat(this.class);
     }
   })
 }
开发者ID:JacobDeming,项目名称:HotfixEngine,代码行数:20,代码来源:player2sprite.component.ts

示例8: constructor

  constructor (af:AngularFire) {
    this.URL=window.location.href;
    this.onOff = af.database.object('/'+this.URL.split('/game/')[1]+'/Globals/OnOff',{preserveSnapshot:true});
    this.onOff.subscribe(snap =>{

      if(this.environmentSnapshot.fog !== snap.val().fog){
        if(snap.val().fog==true){
          this.turnOn("fog");
        } else {
          this.turnOff("fog");
        }
      }
      if(this.environmentSnapshot.lightning !== snap.val().lightning){
        if(snap.val().lightning==true){
          this.turnOn("lightning");
        } else {
          this.turnOff("lightning");
        }
      }
      if(this.environmentSnapshot.quake !== snap.val().quake){
        if(snap.val().quake==true){
          this.turnOn("quake");
        } else {
          this.turnOff("quake");
        }
      }
      if(this.environmentSnapshot.rain !== snap.val().rain){
        if(snap.val().rain==true){
          this.turnOn("rain");
        } else {
          this.turnOff("rain");
        }
      }
      if(this.environmentSnapshot.snow !== snap.val().snow){
        if(snap.val().snow==true){
          this.turnOn("snow");
        } else {
          this.turnOff("snow");
        }
      }
      if(this.environmentSnapshot.storm !== snap.val().storm){
        if(snap.val().storm==true){
          this.turnOn("storm");
        } else {
          this.turnOff("storm");
        }
      }
      /* Updates to new values */
      this.environmentSnapshot = snap.val();
    })
  }
开发者ID:JacobDeming,项目名称:HotfixEngine,代码行数:51,代码来源:animation.component.ts

示例9: constructor

 constructor(af:AngularFire){
   this.URL = window.location.href;
   this.firebaseServer = af.database.object('/'+this.URL.split('/game/')[1],{preserveSnapshot:true});
     this.firebaseServer.subscribe(snap =>{
       this.player1Action = snap.val().Players.player1.lastRound;
       this.player2Action = snap.val().Players.player2.lastRound;
       this.playersInfo = snap.val().Players;
       this.environmentInfo = snap.val().Globals.Environment;
       if (this.playersInfo.player1.currentHitpoints <= 0){
         this.winner = this.playersInfo.player2.playerClass+" IS THE WINNER!";
         this.firebaseServer.update({Ready:0});
         this.ready=false;
       }
       if (this.playersInfo.player2.currentHitpoints <= 0){
         this.winner = this.playersInfo.player1.playerClass+" IS THE WINNER!";
         this.firebaseServer.update({Ready:0});
         this.ready=false;
       }
       if (this.playersInfo.player1.currentHitpoints <= 0 && this.playersInfo.player2.currentHitpoints <= 0){
         this.winner = this.playersInfo.player1.playerClass+" AND "+this.playersInfo.player2.playerClass+" TIED!"
         this.firebaseServer.update({Ready:0});
         this.ready=false;
       };
     });
   this.firebaseClock = af.database.object('/'+this.URL.split('/game/')[1]+"/Timer",{preserveSnapshot:true});
   this.firebaseClock.subscribe(snap =>{
     this.remaining=snap.val();});
   const readyToStart = af.database.object('/'+this.URL.split('/game/')[1]+"/Ready",{preserveSnapshot:true});
   readyToStart.subscribe(snap =>{
     this.playersReady = snap.val();
     if(snap.val()>=2){
       this.resetClock();
       this.runClock();
     }
   })
 }
开发者ID:JacobDeming,项目名称:HotfixEngine,代码行数:36,代码来源:timer.component.ts

示例10:

    this.routerSubscription = this.route.params.subscribe(params => {
      this.discipline = params['type'];
      this.getPresentationName();

      this._idClass = params['id'];
      if (this._idClass !== undefined) {
        this.edit = true;
        this.classObservable = this.cs.getClass(this.discipline, this._idClass);
        this.classSubscription = this.classObservable.subscribe(classT => {
            this.classT = classT;
            if (classT.timeSchedule !== undefined) {
              this.schedule = classT.timeSchedule;
            }
        });
      }
    });
开发者ID:filipemendes1994,项目名称:FUTAdmin,代码行数:16,代码来源:form-classes.component.ts


注:本文中的angularfire2.FirebaseObjectObservable.subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。