當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript firebase.child函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。