fsprojects / FSharp.Control.AsyncSeq

Asynchronous sequences for F#
https://fsprojects.github.io/FSharp.Control.AsyncSeq/
Other
161 stars 59 forks source link

[General Question] #158

Closed Xyncgas closed 1 year ago

Xyncgas commented 1 year ago

If I iterate the AsyncSeq multiple times do I make multiple fetch request

abelbraaksma commented 1 year ago

Depending on how you code “fetch requests”, yes. If your code executes a side effect, each iteration, just like with any enumerable (like seq) will be iterated again.

However, you can apply multiple map or collect operations at once. They won’t execute until the sequence is executed.

AsyncSeq has a function cache that you can use to prevent side effects to run again, while keeping late binding operating semantics (that is: cache doesn’t do anything until you start iterating, and if it gets iterated again, the already cached items won’t execute. If it was a partial iteration, the rest will be cached once needed).

Xyncgas commented 1 year ago

Thanks