You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.
Wouldn't it be better to have the Signal object be a struct rather than a final class. This is ensures safety when copying and is preferred in Swift (as seen in this talk) over classes. Really, I just wanted to know why it was a final class.
The text was updated successfully, but these errors were encountered:
Signals have to be classes so they can be referenced (classes are reference types, structs are not).
leta=Signal<String>()func doSomething(s:Signal<String>){
s.next{ string in// do something important}}doSomething(a)
a.update("Hello")
If Signal would be a value type, doSomething wouldn't be able to change it (it could declare s as inout mutable, but that just breaks the whole concept of sane dependencies). Therefore the signal couldn't add the func as a subscriber and also it cannot call it back. s would never update and call their subscribers, because it would be a different instance than a.
Wouldn't it be better to have the Signal object be a struct rather than a final class. This is ensures safety when copying and is preferred in Swift (as seen in this talk) over classes. Really, I just wanted to know why it was a final class.
The text was updated successfully, but these errors were encountered: