How would one implement publish subscribe / concur...
# arrow
j
How would one implement publish subscribe / concurrency in a functional (arrow) way?
s
+
s
You can build purely functional actors with
Queue, Promise
and recursion.
An easier way of implementing it would be using
Streams
but those are something I’ll work on in 2020.
😍 1
r
For other higher level concurrent stuff https://arrow-kt.io/docs/effects/fx/async/
s
I’ve ported this example in the passed and everything you need is available in Arrow Fx.
t
j
Found this in Arrows documentation: https://arrow-kt.io/docs/effects/async/
If I understand correct, this might do it:
IO.async().run {
// In current thread
invoke(CommonPool) {
// In CommonPool
requestSync(createUserFromId(123))
}
}
t
For this use
continueOn(CommonPool).bind()
or
Copy code
effect {
    withContext(CommonPool) {
        //...
   }
}.bind()
j
Thanks!
👍 1