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

feat!: return promise from field mount fn #1162

Merged
merged 5 commits into from
Mar 20, 2023
Merged

feat!: return promise from field mount fn #1162

merged 5 commits into from
Mar 20, 2023

Conversation

veinfors
Copy link
Collaborator

@veinfors veinfors commented Mar 19, 2023

Return a promise from the field mount function to indicate when all data fetching is done.
This can be used to determine when the listbox finishes rendering.

Awaits data pages to arrive and maxFrequencyCount when needed.

  • Integration test added for verification

@Caele Caele changed the title feat: return promise from field mount fn feat!: return promise from field mount fn Mar 20, 2023
apis/nucleus/src/index.js Outdated Show resolved Hide resolved
@T-Wizard
Copy link
Collaborator

how does it work for supernova objects?
and maybe we should use the same api for fields?

@Caele
Copy link
Collaborator

Caele commented Mar 20, 2023

how does it work for supernova objects? and maybe we should use the same api for fields?

They have an onMount thing that I'm not 100% sure why it actually works. I've looked at making it so that the return "Viz" resolves when the chart is rendered (in my createApi PR) but that was quite the hassle.

I think the Viz resolves when the onMount callback into Cell resolves, which is done when the loadType function finishes. Then there is a renderCount thing in Supernova that also does stuff... pending more reading...

@veinfors
Copy link
Collaborator Author

how does it work for supernova objects? and maybe we should use the same api for fields?

They have an onMount thing that I'm not 100% sure why it actually works. I've looked at making it so that the return "Viz" resolves when the chart is rendered (in my createApi PR) but that was quite the hassle.

I think the Viz resolves when the onMount callback into Cell resolves, which is done when the loadType function finishes. Then there is a renderCount thing in Supernova that also does stuff... pending more reading...

Yeah, I made the assumption that the promise returned from the render function resolves once the supernova has no more outstanding, unresolved, promises (basically the rendering is done...). And then I added this promise return from the field -> mount function to make it work in an equivalent way.

But maybe the render function doesn't work like I assumed...

@T-Wizard
Copy link
Collaborator

how does it work for supernova objects? and maybe we should use the same api for fields?

They have an onMount thing that I'm not 100% sure why it actually works. I've looked at making it so that the return "Viz" resolves when the chart is rendered (in my createApi PR) but that was quite the hassle.
I think the Viz resolves when the onMount callback into Cell resolves, which is done when the loadType function finishes. Then there is a renderCount thing in Supernova that also does stuff... pending more reading...

Yeah, I made the assumption that the promise returned from the render function resolves once the supernova has no more outstanding, unresolved, promises (basically the rendering is done...). And then I added this promise return from the field -> mount function to make it work in an equivalent way.

But maybe the render function doesn't work like I assumed...

It is hard to track but I think it don't wait for the render.
and that you need to use option.onInitialRender to get that for supernova charts

@Caele
Copy link
Collaborator

Caele commented Mar 20, 2023

So I dug:
viz = await nebiie.render(...) will resolve when the Cell has finished loading and creating the chart, not when it is done rendering. So basically when the Viz API is ready. There is an option to pass in (undocumented) called onInitialRender that I had trouble getting to work.
In Nebulas tests we use 'data-render-count' attribute to check if it is done.

In client we call the innermost render function directly, which resolves when all the hook-ing is done.

Christians approach here is fine I think, good if it resolves when rendering is done.

@Caele Caele merged commit 4bdd762 into master Mar 20, 2023
@Caele Caele deleted the field-mount-promise branch March 20, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants