This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script module> | |
/* | |
Sample usage: | |
```svelte | |
<script lang="ts> | |
import AppRouter, { type Router } from "./AppRouter.svelte"; | |
import Login from "./pages/Login.svelte"; | |
import Home from "./pages/Home.svelte"; | |
import Messages from "./pages/Messages.svelte"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/simsieg/sleepjs | |
const { sleep, sleepSeconds, sleepMinutes } = require('sleepjs') | |
// chain sleeps of different intervals | |
async function chainingFunc() { | |
await sleep(500); | |
alert("Hello"); | |
await sleepSeconds(1); | |
alert("Hello"); | |
await sleepSeconds(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/simsieg/sleepjs | |
const { sleep } = require('sleepjs') | |
async function myFunction() => { | |
await sleep(500); | |
alert("Hello"); | |
} | |
myFunction(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.w3schools.com/jsref/met_win_settimeout.asp | |
function myFunction() { | |
setTimeout(function() { | |
alert("Hello"); | |
}, 3000); | |
} | |
myFunction(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://firebase.google.com/docs/firestore/quickstart | |
var db = firebase.firestore(); | |
async function fetchArticle(articleId, authorId) { | |
// get author and article docs simultaneously | |
const authorPromise = db.doc("authors/" + authorId).get(); | |
const articlePromise = db.doc("articles/" + articleId).get(); | |
// wait until both compleeted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://firebase.google.com/docs/firestore/quickstart | |
var db = firebase.firestore(); | |
async function fetchArticle(articleId, authorId) { | |
try { | |
// get author and article docs sequentially | |
const authorSnap = await db.doc("authors/" + authorId).get(); | |
const articleSnap = await db.doc("articles/" + articleId).get(); | |
} | |
catch (err) {/* handle error */} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://firebase.google.com/docs/firestore/quickstart | |
async function main() { | |
try { | |
const doc = await db.doc("user/" + uid).get() | |
if (doc.exists) { | |
console.log("User data:", doc.data()); | |
// use fetched data, for example in setState() | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://firebase.google.com/docs/firestore/quickstart | |
const userPromise = db.doc("user/" + uid).get().then(doc => { | |
if (doc.exists) { | |
console.log("User data:", doc.data()); | |
// use fetched data, for example in setState() | |
} else { | |
console.warn("No user data."); | |
} | |
}).catch(error => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://firebase.google.com/docs/firestore/quickstart | |
var db = firebase.firestore(); | |
const userPromise = db.doc("user/" + uid).get(); | |
const articlePromise = db.doc("article/1").get(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:sensors/sensors.dart'; | |
class SensorsTest extends StatefulWidget { | |
SensorsTest({Key key}) : super(key: key); | |
@override | |
_SensorsTestState createState() => _SensorsTestState(); | |
} |
NewerOlder