If there is one word I would use to describe what we have done so far it would be: “wow”.
In just one line of code we are expressing the idea of sharing a piece of state with the file system. Using @Shared
with file storage looks almost identical to using @Shared
with user defaults, but it works beautifully for more complex data types. Any change made to the shared state is automatically saved to disk, and if anyone else every saves data straight to that file, the @Shared
state in the app will immediately update.
But things get even better. Even though the @Shared
property wrapper typically is interacting with outside systems that we do not control, such as user defaults and the file system, it was still built in a way that makes it possible to test any of your code using @Shared
. And can be done so with no additional setup work too.
It’s amazing to see, so let’s write a very basic test for our feature.