You don't want generateM
, it's for building enumerators that can return multiple values. generateM
takes a function that either returns a Some
, to produce the next value for the Enumerator
, or None
, to signal that the Enumerator
is complete. Because your function always returns Some
, you create Enumerator
s that are infinite in length.
You just want to convert a Future
into an Enumerator
, to create an Enumerator
with a single element:
Enumerator.flatten(future.map(Enumerator(_)))
Also, you can interleave your enumerators and then feed the result into EventSource()
. Parenthesis are unnecessary as well (methods that start with >
have precedence over methods with &
).
enumerator1 >- enumerator2 &> EventSource()