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
Would it be kosher to include a weak reference to a delegate (i.e. a ViewController) in the context so that the component can set its controller's delegate?
Is that a valid pattern (I suspect possibly not)? Are there better ways to route events?
Specifically, I want to implement the tap on a couple of buttons in a component to present view controllers from the current one, and was wondering what strategies are preferred to connect component actions back to their owning view controllers.
The text was updated successfully, but these errors were encountered:
Would it be kosher to include a weak reference to a delegate (i.e. a ViewController) in the context so that the component can set its controller's delegate?
Yes (although I'd prefer having the controller read the component's weak reference and set it on itself, rather than having the component do it).
Are there better ways to route events?
The way we do it at Facebook: we pass down a "navigator" object as part of the context. A simplified version:
Behind the scenes, the actual implementation holds a weak reference to the parent view controller. On demand it looks up the view controller's navigation controller and pushes a view controller, etc.
We find this hides the actual view controller away from the components, making them more reusable.
Would it be kosher to include a weak reference to a delegate (i.e. a ViewController) in the context so that the component can set its controller's delegate?
Is that a valid pattern (I suspect possibly not)? Are there better ways to route events?
Specifically, I want to implement the tap on a couple of buttons in a component to present view controllers from the current one, and was wondering what strategies are preferred to connect component actions back to their owning view controllers.
The text was updated successfully, but these errors were encountered: