Replies: 1 comment 1 reply
-
This is definitely interesting idea, and @tgrapperon has shared some explorations into this area recently too. I think currently we do not want to invest too much more time in building out niceties for return .run { send in
await withTaskGroup(Void.self) { group in
group.addTask {
for await value in environment.sequence() {
send(.update(value))
}
}
group.addTask {
send(.updateOther(await environment.fetch()))
}
}
} This |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
For certain actions, several effects can be created and needed to be merged together. One pattern I use is to have a
.start
action where I start all sorts of subscription for pulling external data. In such cases, I find myself have to manually merge effects. There are three ways to do that, but IMO none of them are perfect:Effect.merge
likeReducer.combine
.Effect.merge(...)
at last.effects.append(someMultilinePublisher.eraseToEffect)
.This is not totally unbearable, but wouldn’t it be nice to have a result builder? We no longer need to worry about the commas, no more
eraseToEffect
, no more variable naming. Plus we can also support it/switch/for-loops.A naïve implementation could look like this:
Then we can write something like:
instead of
Beta Was this translation helpful? Give feedback.
All reactions