-
Notifications
You must be signed in to change notification settings - Fork 84
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
Help to build control flow func #193
Comments
I've made this implementation, but behavior of count() is very weird !!! const throughLimit= (fn, stream, maxConcurrency) => { Can we update a dependant stream inside a combine() body ? |
let's forget the first buggy implementation! it's called as: Does anyone have a better idea ? const throughLimit= (fn, stream, maxConcurrency) => { |
You could use ramda to help you there Maybe something like this could do the trick for you? const urlStream = flyd.stream() // Stream string
const joinedUrlStream = urlStream
.pipe(flyd.scan(R.flip(R.append), [])) // Stream [string]
const requestStream = joinedUrlStream
.map(R.splitEvery(1000)) // Stream [[string]]
.map(async splitUrls => {
let result = []
for (const urls of splitUrls) {
result = result.concat(await Promise.all(urls.map(makeRequest)))
}
return result
}) // Stream Promise [Result]
const responseStream = requestStream
.chain(flyd.fromPromise) // Stream [Result] |
I can't find a way to build a control flow system to pop values from a stream until a concurrency limit.
const urls = reduce((stream, url) => stream(url), flyd.stream(), R.times(makeUrl(), 1000));
const results = throughLimit(requestUrl, urls, { maxConcurrency });
// only maxConcurrency requests can be pending at a time
// result from requestUrl() are pushed one by one in results
Thanks for your help.
Eric.
The text was updated successfully, but these errors were encountered: