https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
toTask(getUser()
.then(populateGroups)
.then(checkDriver)
.then(getTrips)
.then(getAddresses)
).andThen(render)
var { token, cancel } = CancelToken.source();
getUsers({}, token).then(render)
cancel();
async function getUsers (data, token) {
var users = await getUsersFromDB(data, token);
token.throwIfRequested();
let fullUsers = await populateUsers(users, token);
token.throwIfRequested();
return fullUsers;
}
async function getUsers (data, token) {
await.cancelToken = token;
var users = await getUsersFromDB(data, token);
let fullUsers = await populateUsers(users, token);
return fullUsers;
}
function* getNumbers() {
yield 42;
yield 24;
return 1;
}
function* getLines () {
var reader = new FileReader("Some.txt");
while (!reader.oef) {
let line = reader.readLine();
yield JSON.parse(line);
}
reader.close();
return "";
}
async function* getLines () {
var reader = new AsyncFileReader("Some.txt");
while (!reader.oef) {
let line = await reader.readLine();
yield JSON.parse(line);
}
await reader.close();
}
var iterator = getLines();
iterator.next().then(() => {});
iterator.next().then(() => {});
iterator.next().then(() => {});
iterator.next().then(() => {});
for await(let line of getLine()) {
// here is line
}
interface Observer<T> {
next (data: T): void,
error (e: Error): void,
complete (data: T): void
}
interface Observable<T> {
subscribe (obs: Observer<T>, cancelToken): {
unsubscribe (): void
}
}
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener