-
Notifications
You must be signed in to change notification settings - Fork 395
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
When Iterate is not clear enough .... #454
Comments
Just for the record, what is "require" for ? |
It is not clear to me what is the result of iterate, in the sense that when iterate stops, what argument is passed to done(). What it deferred resolve to ? |
Hey @Maatary. I'll try to answer some of your questions. In general, Does that help?
Are you asking about the
The promise returned by when.iterate(...).then(function(x) {
// x is the value from the final iteration of when.iterate
}); If you use If you haven't already read then vs. done, or the debugging promises section, you may find them to be helpful. Hope that helps! |
Could you let me know how with iterate I could solve my use case. The On each element of the table I want to know if A is a narrower concept or a So the result of is_broader or is_narrower are promises. That either true Depending on their result I want to continue up the chain or not. And get So long as handler is for side effect I don't see how I can impact the
|
Generates a potentially infinite stream of promises by repeatedly calling f until predicate becomes true.
Where:
f - function that, given a seed, returns the next value or a promise for it.
predicate - function that receives the current iteration value, and should return truthy when the unfold should stop
***handler - function that receives each value as it is produced by f. It may return a promise to delay the next iteration.
seed - initial value provided to the handler, and first f invocation. May be a promise.
The question is what is handler for exactly ?
In my case:
1 - i have a table of values
2 - for each value i need to check if a value X, is not related to the value of the tables.
2.2 - In that respect obtaining the related element of a value requires making an AJAX call.
2.3 - Then upon getting the result of related value, i check if the value X is not in that result.
2.4 - If it is i'm done. If not i repeat the task with the next value in the table.
I have the feeling that iterate is suited for that.
1 - However i don't understand how the handler can help me.
2 - I feel one could give as a seed, an object {table: tab, iter: 0}, then the next function would simply change the iter value and return the object.
3 - The issue is with predicate and handler.
3.1 - I need to make an ajax call, get my result and compare. Can the result of predicate be a promise ?
The text was updated successfully, but these errors were encountered: