Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Return value of waitUntil()? #3

Open
inexorabletash opened this issue Sep 26, 2015 · 2 comments
Open

Return value of waitUntil()? #3

inexorabletash opened this issue Sep 26, 2015 · 2 comments

Comments

@inexorabletash
Copy link
Owner

Options include:

  1. a Promise dependent on the promise the transaction is waiting on
  2. just whatever is passed in
  3. undefined

1 is redundant with .complete
2 is not terribly helpful
3 is what ExtendableEvent is defined as

So 3 probably makes the most sense and leaves room to change it in the future.

@inexorabletash
Copy link
Owner Author

In email to public-webapps, @domenic suggests returning tx.complete as a convenience.

@inexorabletash
Copy link
Owner Author

inexorabletash commented Sep 13, 2016

As hinted at in #9 it may be convenient to make it a pass-through so you can write e.g.

  const url = await tx.objectStore('urls').get(key);
  const request = await tx.waitUntil(fetch(url));
  const text = await tx.waitUntil(request.text());
  tx.objectStore('bodies').put(text, key);

.... which looks better than the "IIAFE" alternative:

tx.waitUntil((async () => {
  const url = await tx.objectStore('urls').get(key);
  const request = await fetch(url);
  const text = await request.text();
  await tx.objectStore('bodies').put(text, key);
})());

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant