Skip to content
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

Why don't you have weak delagates in VIPER ? #18

Open
alphabikram opened this issue Jun 19, 2017 · 1 comment
Open

Why don't you have weak delagates in VIPER ? #18

alphabikram opened this issue Jun 19, 2017 · 1 comment

Comments

@alphabikram
Copy link

Why there are strong delegate references ??
I get my class nil when setting weak delegate . But delegate should be weak , isn't it ?

@zntfdr
Copy link
Contributor

zntfdr commented Dec 20, 2017

You're right: there are no weak references in the project.
Actually there many strong reference cycles, I found a few just by looking at the AppDependencies.swift file (e.g. ListPresenter and ListWireframe reference to each other, same for ListPresenter and ListInteractor, and AddWireframe and AddPresenter).

Some of these references (most of them) are optionals, but they still are strong references.

The ideal would be to have the ListViewController to strong reference the ListPresenter, and all the other references to ListPresenter weak (from ListWireFrame, ListInteractor, and AddPresenter).
Therefore when the VC is deinitialized you have a chain-reaction where every other part of the VIPER architecture for that view is deinitialized.

The problem in this project is that the ListviewController is initialized after the dependencies are already set up, therefore what I suggest above is not implementable without some code changes (that are more than just adding weak here and there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants