• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript firebase.child函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中firebase.child函数的典型用法代码示例。如果您正苦于以下问题:TypeScript child函数的具体用法?TypeScript child怎么用?TypeScript child使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: startWatching

  startWatching() {
    this.movesRef = this.rootRef.child('moves')

    this.actionRef = this.rootRef.child('action')
    this.actionRef.on('value', onlineSnap => {
      const val = onlineSnap.val()
      if (val == null) {
        this.resetGame()
        return
      }
      switch (val.action) {
      case Action.PUT:
        console.log(val)
        const stone: Stone = val.playerId + 1
        if (this.board.turn == stone &&
            this.board.canPut(val.x, val.y, stone)) {
          this.movesRef.push({x: val.x, y: val.y, stone})
          this.board.putStone(val.x, val.y, stone)
          if (this.board.gameOver) {
            this.finishGame()
          }
        }
        break
      }
    })
    console.log('Start watching...')
  }
开发者ID:tyfkda,项目名称:fire-reversi,代码行数:27,代码来源:server.ts


示例2: resetGame

  resetGame() {
    console.log('Reset game')
    this.board = new Board()
    this.board.startGame(0)

    this.rootRef.child('action').remove()
    this.rootRef.child('moves').remove()
  }
开发者ID:tyfkda,项目名称:fire-reversi,代码行数:8,代码来源:server.ts


示例3: Promise

		return new Promise((resolve, reject) => {
			if (!keyExists(key)) return reject();
			this.ref.child(key).remove((error) => {
				if (error) reject(error);
				else resolve();
			});
		});
开发者ID:truongndnnguyen,项目名称:ng2-lab,代码行数:7,代码来源:firebase_array.ts


示例4: getItems

 getItems():Promise<Array<any>> {
     let promise:Promise<Array<any>>;
     this.firebaseRef.child("/").on("value", function(snapshot) {
         let items = [];
         items.push(snapshot.val());
         // items.push(new ProductModel("Maggara"));
     });
     return promise;
 }
开发者ID:tkarling,项目名称:recipeshopper2,代码行数:9,代码来源:firebase-repository.ts


示例5:

export const clearCompleted = ({user, tab}: ActionContext) => (dispatch) => {
    let tasks = dbRoot.child(`${user.userId}/${getTabProp(tab)}`);
    tasks.once('value', snapshot => {
        snapshot.forEach(todo => {
            const { completed } = todo.val() as Todo;
            if (completed) {
                tasks.child(todo.key()).remove();
            }
        })
    });
};
开发者ID:jtmueller,项目名称:checked-past,代码行数:11,代码来源:todos.ts


示例6: next

  next() {
    let category = "cat" + Math.floor((Math.random() * 3) + 1);
    let id = "id" + Math.floor((Math.random() * 10) + 2001);
    let name = "Joe" + Math.floor((Math.random() * 900) + 1001);
    let score = Math.floor((Math.random() * 100) + 1);

    this.ref.child(category).child(id).set({
      name: name,
      score: score,
      present: score>2
    });
  }
开发者ID:hansanker,项目名称:angular2-firebase-demo,代码行数:12,代码来源:activityGenerator.ts


示例7: User

			query.then((users: Map<string, any>) => {
				if (users.size) {
					// Found the user.
					// Check if providers contains the current `auth.provider` and update the user providers if it does not contain it.
					let {key, providers} = Array.from(users.values())[0];
					if (Array.isArray(providers) && providers.includes(auth.provider)) resolve(
						new User({key, email, providers})
					);
					else {
						let firebaseUserProvidersRef = firebaseUsersRef.child(key).child('providers');
						let observable = new FirebaseQueryObservable(firebaseUserProvidersRef, [
							FirebaseQueryEventType.Value
						]);
						let first = true;
						let subscription = observable.subscribe((event: FirebaseQueryEvent) => {
							if (first) first = false;
							else {
								let user = new User({key, email, providers: event.data.val()});
								subscription.unsubscribe();
								resolve(user);
							}
						});
						firebaseUserProvidersRef.set(
							Array.isArray(providers)
								? providers.concat([auth.provider])
								: [auth.provider]
						);
					}
				} else {
					// Could not find the user.
					// If no user could be found we need to create one.
					// After user is saved, resolve the promise with the newly created user.
					let providers = [auth.provider];
					usersArray.add({email, providers}).then((ref: Firebase) => {
						let key = ref.key();
						let firebaseUserKeyRef = ref.child('key');
						let observable = new FirebaseQueryObservable(firebaseUserKeyRef, [
							FirebaseQueryEventType.Value
						]);
						let first = true;
						let subscription = observable.subscribe(() => {
							if (first) first = false;
							else {
								let user = new User({email, providers, key});
								subscription.unsubscribe();
								resolve(user);
							}
						});
						firebaseUserKeyRef.set(key);
					});
				}
			});
开发者ID:truongndnnguyen,项目名称:ng2-lab,代码行数:52,代码来源:user.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript firebase.database函数代码示例发布时间:2022-05-25
下一篇:
TypeScript firebase.auth函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap