Unfortunately, this is also perhaps surprising, and goes against the grain when folks might expect to be handed a Shared<Value?>.
Also, there are times when you have a Shared<Value?> already, and you want to unwrap it. Dynamic member lookup doesn't help there (unless you know you can call $shared[dynamicMember: \.self]), and so you need a totally different operation to handle it:
if let unwrappedShared = Shared($optional) {
// Do something with 'Shared<Value>'
}
So let's avoid this confusion in the future and focus on a single API for unwrapping shared values, which is the failable initializer that mirrors an API on Binding.
Currently,
Shared
's dynamic member lookup is overloaded for convenience:Unfortunately, this is also perhaps surprising, and goes against the grain when folks might expect to be handed a
Shared<Value?>
.Also, there are times when you have a
Shared<Value?>
already, and you want to unwrap it. Dynamic member lookup doesn't help there (unless you know you can call$shared[dynamicMember: \.self]
), and so you need a totally different operation to handle it:So let's avoid this confusion in the future and focus on a single API for unwrapping shared values, which is the failable initializer that mirrors an API on
Binding
.