Replies: 1 comment 1 reply
-
Hi @wltrup, it seems like you are able to accomplish this without any changes to the library: extension SharedReaderKey
where Self == FileStorageKey<IdentifiedArrayOf<User>>.Default {
static var users: Self {
Self[
.fileStorage(URL(/* ... */)),
default: (try? JSONDecode(/*load data here*/)) ?? []
]
}
} |
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.
-
Hello,
In Reusable, type-safe keys, you have
as an example of how to define a reusable type-safe key that also implicitly defines a default value for the shared quantity. In this particular example the default is an empty array but what if the default is some (possibly large) set of predefined values?
It would be nice if it was possible to define the default by means of a URL to a file containing the default data, perhaps along the lines of
The first URL points to the usual "live" file while the second URL would point to a read-only file containing the data to be used as the default.
Is this something you would consider adding to the library?
Many thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions