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

should call finishUpdateItems to finalize updateItems #1

Closed
t9md opened this issue Jun 4, 2017 · 2 comments
Closed

should call finishUpdateItems to finalize updateItems #1

t9md opened this issue Jun 4, 2017 · 2 comments
Projects

Comments

@t9md
Copy link

t9md commented Jun 4, 2017

I noticed this from GIF, where updating indicator (x icon) remain running state.

This is because ProviderBase.protototype.finishUpdateItems is not called.
Updating items must be finalized to notify narrow-ui to finish updating.

Basically you have two pattern to finalize

  • Option-1:

    • finishUpdateItems(items): Use this if you update items in single response against request from UI.
  • Option-2:

    • updateItems(items): You can update(render) items multiple times against single request.
    • finishUpdateItems(): Then finalize with empty arg.

Why narrow provide option-2 is, search provider collect items on each data event of event emitter which is emitted multiple-time.
So when you search foo, the result is updated separately on each data event.
This prevent big items consume huge heap memory and blocking event-loop long-time while preparing new item-list on UI.

@lettertwo
Copy link
Owner

Thanks for checking the provider out!

I'm trying to figure out the right way to sync narrow UI updates with the diagnostics service updates, but i haven't quite figured it out yet. If you don't mind, i have a few questions about this:

  1. after finishUpdateItems(), can i updateItems() again?

  2. the Diagnostics service pushes updates to the narrow provider; do you have a recommendation for triggering narrow UI updates in this scenario? So far i've come up with this hack.

@t9md
Copy link
Author

t9md commented Jun 4, 2017

after finishUpdateItems(), can i updateItems() again?

Whole flow is this

  1. Type something on UI, that trigger ui.refresh
  2. it eventually call provider.getItems
  3. in provider's getItem, send items to ui by updateItems(items), then finalize finishUpdateItems(), finishUpdateItems(items) is shorthand of update then finish.

Each time, ui call ui.refresh(), provider.getItems is called unless it can use cached(by ui) items.
So while narrow-ui is opened, narrow is repeating 1-3 flow, on each trigger of ui.refresh

the Diagnostics service pushes updates to the narrow provider; do you have a recommendation for triggering narrow UI updates in this scenario? So far i've come up with this hack.

Humm, it's difficult, you can manually fire ui.refresh(force: true) from provider by provider.ui.refresh(force: true).

So, if you can subscribe event to update diagnostics push, then fire provider.ui.refresh?

Also refer narrow bundled core-providers to get some ideas.

lettertwo added a commit that referenced this issue Jun 6, 2017
@t9md t9md closed this as completed Jun 29, 2017
@lettertwo lettertwo added this to Done in 1.0 Aug 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
1.0
Done
Development

No branches or pull requests

2 participants