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

sequentially perform actions that require source retrieval at same time #708

Open
bmhardy opened this issue Feb 1, 2017 · 2 comments
Open

Comments

@bmhardy
Copy link

bmhardy commented Feb 1, 2017

Can we have the ability to sequentially perform actions that require source retrieval at same time?

class SearchStore {
  constructor() {
    this.state = { value: '' };

    this.registerAsync(SearchSource);
  }
  onSearch() {
    if (!this.getInstance().isLoading()) {
      this.getInstance().performSearch();
    }
  }
}

Note the isLoading call. What can I do when I have multiple components relying on the same store that want to call onSearch (via an action) at (relatively) the same time. The second call will come while the store "isLoading" the results for the first call, and thus the second call will do nothing? Is there an Alt way that I can queue up multiple calls while one is taking place?

@snags88
Copy link

snags88 commented Feb 1, 2017

@bmhardy i haven't seen any out of the box functionality for this, but you could build the functionality with a concept of a QueueStore that can act as your queue of asynchronous calls you need to make.

You probably want to move the "should make async call" logic into your source as part of your shouldFetch function. And in there you could trigger actions to add to the queue if the SearchStore is loading. Once the store is done loading, you could work off your queue until it's empty.

Hope that was somewhat helpful.

@snags88
Copy link

snags88 commented Feb 1, 2017

@bmhardy also, i am curious about the usecase of having multiple searches occur at the same time

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

No branches or pull requests

2 participants