Bikeshedding names for StoreTask.finish()
#3116
Replies: 3 comments 13 replies
-
Use of I'd also like to point out that your dislike of various options due to checking state rather than waiting for something doesn't seem true, given the use of Personally, and given Unfortunately Apple has stopped updating the Swift naming guidelines as Swift adds new capabilities like native concurrency, so there's really no official guidance here. |
Beta Was this translation helpful? Give feedback.
-
Another possibility that occurred. What if we had an enum that indicated that outcome, and a property to check the result. Something like: extension StoreTask {
public enum Completion {
case finished
case cancelled
}
public var completion: Completion {
get async {
await self.rawValue?.cancellableValue
return self.isCancelled ? .cancelled : .finished
}
}
} This would then be used as: await store.send(.action).completion |
Beta Was this translation helpful? Give feedback.
-
I like completion but I don't think a car can be @discardableResult so it would require to write _ = await store.send(.action).completion What about having an async counterpart to .send() that just conveys the fact that it does not just send but also wait for all effects to run? await store.run(.action) Or eventually await store.reduce(.action) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It was mooted in Slack that the
StoreTask.finish()
name feels ambiguous in its intention. The designed usage is something like:However, because
finish
is an imperative verb, it may feel like it's a command to finish, rather than waiting for the task to finish.There is some prior art from Apple for using
waitXXX
:It does feel somewhat redundant having
await
andwait
in the statement. For example:Other possible options suggested include:
await store.send(.action).finished()
await store.send(.action).untilFinished()
await store.send(.action).hasFinished()
None of these really have prior art in an async sense.
I would also say that it should make sense if just checking on the
StoreTask
directly. For example:Of these, my favourite is actually probably
hasFinished
orhasCompleted
. It's more clearly a 'past tense' phrase thanisFinished
. But it's not really out there much as a convention.Otherwise,
waitUntilFinished
orwaitUntilCompleted
would be clearer than what we have at the moment.What are people's thoughts or suggestions?
Beta Was this translation helpful? Give feedback.
All reactions