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 ?
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 ?