Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the expected behavior of inserting without awaiting runAsync? #2513

Closed
domoritz opened this issue Apr 7, 2020 · 3 comments
Closed
Labels
documentation For documentation-related issues

Comments

@domoritz
Copy link
Member

domoritz commented Apr 7, 2020

I am wondering about the expected behavior when I run something like

for (const i of [1,2,3,4,5,6,7,8,9,10]) {
  view.insert("foo", [{a: i, b: i}]).runAsync()
}

Vega does not process all insertions and therefore some data points are missing.

Screen Shot 2020-04-06 at 17 50 53

The docs say that I should call `runAsync' after inserting some data but do not specify that I have to await them.

Would it make sense to queue updates here?

Working example at http://bl.ocks.org/domoritz/d5dfd5d195aa7dc838999a25f2dfae02/a82bd83499389296ab6cfcf8987aacbb7eaf5dc4

@domoritz domoritz changed the title What's the expected behavior inserting without awaiting runAsync? What's the expected behavior of inserting without awaiting runAsync? Apr 7, 2020
@roying
Copy link

roying commented Apr 8, 2020

The issue may not be specific to view.insert() but to view.runAsync() in general. In Vega View API documentation, await is required when view.runAsync() is used within an async function:
https://vega.github.io/vega/docs/api/view/

image
Adding await gives the expected result.

.then(async (result) => {
      const view = result.view;
      
      for (const i of [1,2,3,4,5,6,7,8,9,10]) {
        await view.insert("foo", [{a: i, b: i}]).runAsync()
      }

image

@jheer jheer added the documentation For documentation-related issues label Apr 8, 2020
@jheer
Copy link
Member

jheer commented Apr 8, 2020

The expected behavior is that one should use await (or Promise chaining) before issuing additional changesets. (As currently implemented, applying a new changeset such as an insert before a previous one has been processed can overwrite the prior changeset.) At minimum, we should update the documentation to reflect this.

@jheer
Copy link
Member

jheer commented Apr 23, 2020

Fixed in db60923.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation For documentation-related issues
Projects
None yet
Development

No branches or pull requests

3 participants