-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make public classes open #884
Comments
Hi @kl , This is actually ok behavior. Why do you think you need to subclass |
Hi! In my project I have two frameworks, a Model framework and a View framework. The Model framework is responsible for making network request, parsing JSON and so on. Int the Model framework I have an object called State
An instance of this object is references by the some classes in the Model and also by the View. The View subscribes to the variables in the State to update the UI. The Model in turn updates the State when new data is fetched. This works but I don't want the View framework to be able to write the State, only register as a subscriber. Right now the View can mutate the State because the Variables have to be public, and then the View can just call So to solve this I thought I could subclass variable and overwrite the public Actually now that I wrote this down I thought of another way to do it:
That works but it's a bit noisy. Maybe there's a better way that I'm missing? |
This is an issue beyond that too. For example There are a lot of libraries and extensions of code out there that subclass all sorts of things. Currently, they cannot ever be fixed without swizzling because of |
Hi @kl , you don't need every gistsAsDriver.asObservable() Hi @krider2010 , I didn't say we won't make any public classes open, just that I don't think it would be good idea to make Can you maybe provide us with some examples of problems so we can discuss them here? |
Hello. I got into same problem when tried to add reactive behavior to SpriteKit nodes. |
Sure @kzaher Once simple example (I kind of gave up migrating stuff after finding this issue) is that to make |
@kzaher So if I do someVariable.asDriver().asObservable() is that semantically the same as calling someVariable.asObservable()? Or will the former always be observed on the main thread because it was converted to a driver in the middle? |
Hi guys, ok, so ... @evgeny-sureev unsure what you mean by problems with @krider2010 we can make
yes |
Sorry, it was my mistake. |
+1 on making |
I've made all of those suggested methods on Closing this one for now. |
Short description of the issue:
Classes such as Variable have a public access modifier. Since Swift 3 this means that they cannot be subclassed from outside of the RxSwift module.
see: 0117-non-public-subclassable-by-default
Self contained code example that reproduces the issue:
Xcode version:
Expected outcome:
I should be able to subclass for example Variable from my code.
What actually happens:
You get the error message: "Cannot inherit from non-open class 'Variable' outside of its defining module"
The text was updated successfully, but these errors were encountered: