- 元件載入時: B -> D -> E -> A -> C -> B -> D -> A
- 按下按鈕: D -> E -> A
- 請估算 getTeamLeaderInformation 的平均時間複雜度: O(n ^ 4)
| const axios = require("axios"); | |
| + const aws = require("aws-sdk"); | |
| + const s3 = new aws.S3(); | |
| + const bucketName = "test-firebase-dynamic-links"; | |
| + const s3FileName = "links_map.json"; | |
| + function getDataFromS3() { | |
| + const params = { | |
| + Bucket: bucketName, |
| const aws = require("aws-sdk"); | |
| const s3 = new aws.S3(); | |
| const bucketName = "test-firebase-dynamic-links"; | |
| const s3FileName = "links_map.json"; | |
| function getDataFromS3() { | |
| const params = { | |
| Bucket: bucketName, | |
| Key: s3FileName, |
| const axios = require("axios"); | |
| const headers = { | |
| "Access-Control-Allow-Headers": "Content-Type", | |
| "Access-Control-Allow-Origin": "*", | |
| "Access-Control-Allow-Methods": "OPTIONS,POST,GET", | |
| } | |
| exports.handler = async (event) => { | |
| const queryString = event.queryStringParameters || {}; |
| import { Machine, interpret } from 'xstate'; | |
| // This machine is completely decoupled from React | |
| export const toggleMachine = Machine({ | |
| id: 'toggle', | |
| initial: 'inactive', | |
| states: { | |
| inactive: { | |
| on: { TOGGLE: 'active' } | |
| }, |
| firebase.database().ref('user-datas').on('value', snapshot => { | |
| console.log(snapshot.val()); | |
| }); |
| <button onclick="setData()">set</button> | |
| <script> | |
| function setData() { | |
| firebase.database().ref('user-datas').set({ | |
| username: 'dylan', | |
| email: '[email protected]' | |
| }); | |
| } | |
| </script> |
| <button onclick="getData()">get</button> | |
| <script> | |
| function getData() { | |
| const docs = db.collection("to-do-list").doc("to-do"); | |
| docs | |
| .get() | |
| .then(doc => { | |
| if (doc.exists) { |
| <button onclick="setData()">set</button> | |
| <script> | |
| const db = firebase.firestore(); | |
| function setData() { | |
| db.collection("to-do-list").doc("to-do").set({ | |
| item: "處理 ...", | |
| date: "20XX-XX-XX", | |
| desctiption: "...", |
| // 一般寫法 | |
| let temp = true | |
| if (temp) { | |
| todoSomething() | |
| } | |
| // 短路求值 | |
| temp && todoSomething() |