Skip to content

Key path value type with IdentifiableArrayOf<> #874

Answered by stephencelis
dmeehan1968 asked this question in Q&A
Discussion options

You must be logged in to vote

@dmeehan1968 Store.scope actually takes a transform function and not a key path. When you see the key path it's because key path literals can often be used as a shorthand for a function.

The following, for example, are equivalent:

users.map { $0.name }
users.map(\.name)

I think the problem you're encountering is this bug (or rather, a bug related to this bug):

https://bugs.swift.org/browse/SR-12422

Hopefully it will be fixed some day, but in the meantime, you should be able to get by with an identity closure instead:

self.store.scope(state: { $0 }, action: ItemListAction.item(id:action:)),

Replies: 1 comment 1 reply

Comment options

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

Answer selected by dmeehan1968
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