Dexie.async()
Syntax
var myAsyncFunction = Dexie.async(function* () {
// Function body goes here.
// To await, use the yield keyword.
});Return Value
Description
Using function*() and yield
Using async / await
Sample
var myAsyncFunction = Dexie.async(function* () {
var db = new Dexie("TestDB");
db.version(1).stores({foo: ',bar'});
try {
yield Dexie.delete("TestDB");
yield db.open();
yield db.foo.add({bar: "foobar"}, 1);
var items = yield db.foo.toArray();
console.log(items.length);
} finally {
db.close();
}
});
myAsyncFunction().catch(e => console.error(e));