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
When using react and redux, there is a module called react-redux that is the inspiration for ReRxSwift. Using that module allows you to cleanly separate stateful and pure components. I would like to make view controllers strictly pure as well, meaning that they have no explicit dependency on anything other than their props and actions. In the current form, this is broken by the requirement to have a connection property in your view controller, which needs the application store as one of its parameters.
ReRxSwift can only be implemented if your view controller has two additional properties: props and actions. The current implementation uses protocol extensions to reduce the requirement to one single connection property; props and actions are forwarded to the connection instance.
In general, properties can be added to classes by defining subclasses, or by using the Objective-C runtime in the form of associated objects. I don't like the subclass-route, because if ReRxSwift would provide a ViewController subclass that you have to use, you can no longer benefit from UITableViewController, UICollectionViewController, etc. And the Objective-C route is not desirable because it breaks Swift strong typing, and because I'm not convinced that it is very future-proof as a similar mechanism doesn't exist in Swift.
Do you have any ideas on how to improve this?
The text was updated successfully, but these errors were encountered:
Well, to separate things even more you can inject connection into view controllers using Swinject оr any other DI container. This will move initialization of connection with store and other things to some external class, leaving view controller without explicit dependency on store
Indeed @egv, that's an option that I hadn't considered yet, thanks! At this moment I don't feel like including it in my framework, because I don't want to require the additional complexity of DI for people to use this, but I can definitely see cases where you would want to solve it that way.
When using
react
andredux
, there is a module calledreact-redux
that is the inspiration for ReRxSwift. Using that module allows you to cleanly separate stateful and pure components. I would like to make view controllers strictly pure as well, meaning that they have no explicit dependency on anything other than theirprops
andactions
. In the current form, this is broken by the requirement to have aconnection
property in your view controller, which needs the application store as one of its parameters.ReRxSwift can only be implemented if your view controller has two additional properties:
props
andactions
. The current implementation uses protocol extensions to reduce the requirement to one singleconnection
property;props
andactions
are forwarded to theconnection
instance.In general, properties can be added to classes by defining subclasses, or by using the Objective-C runtime in the form of associated objects. I don't like the subclass-route, because if ReRxSwift would provide a
ViewController
subclass that you have to use, you can no longer benefit fromUITableViewController
,UICollectionViewController
, etc. And the Objective-C route is not desirable because it breaks Swift strong typing, and because I'm not convinced that it is very future-proof as a similar mechanism doesn't exist in Swift.Do you have any ideas on how to improve this?
The text was updated successfully, but these errors were encountered: