Skip to content

Scope vs reduce(into:action:) #3004

Answered by mbrandonw
vyachesIavskiy asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @vyachesIavskiy, there really shouldn't be too much of a performance concern to using Scope. The biggest cost is to using key paths in Swift, which unfortunately are a little bit slower than direct property access, but hopefully that will be fixed some day.

However, I still don't think it's a good idea to reduce on the State and Action.View as you are doing in the view computed property:

@ReducerBuilder<State, Action.View>
private var view: some Reducer<State, Action.View> {

Such a reducer can only send view actions from effects, which is usually not what you would do if you are separating your view actions from your "internal" actions. I don't really think there is a concept of a "vie…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vyachesIavskiy
Comment options

Answer selected by vyachesIavskiy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants