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

How to resolve dependency cycle? #439

Open
alexvbush opened this issue Sep 14, 2022 · 2 comments
Open

How to resolve dependency cycle? #439

alexvbush opened this issue Sep 14, 2022 · 2 comments

Comments

@alexvbush
Copy link

I am going through migrating a legacy codebase onto using Needle and encountered circular dependencies. Some of my scopes have children scopes that in turn declare one of the great great parent components as their dependency, hence the dependency cycle.

The scenario I'm dealing with isn't necessarily an error - the UI I have is for users browsing through folders which means the user can open one folder and then another subfolder and then another infinitively showing the same UI/component as a child of the previous one. Think dropbox file browsing.

The issue I'm experiencing won't be a problem at runtime but since Needle is trying to resolve the dependency tree before compile time so that it can be deterministic and correct at compile time it can't really process it.

How can this be resolved? Some sort of a "break" at some point with BootstrapComponent creating a second parallel dependency tree for the part of the app I want to circularly depend on?

@alexvbush
Copy link
Author

Also, if I get an output like this from a needle call LocationContextMenuListComponent->LocationDetailTabsViewControllerComponent->WorkOrderDetailsLocationSectionComponent->WorkOrderDetailsViewModelComponent->WorkOrderDependencyContainerComponent->WorkOrderDetailsCoordinatorComponent->WorkOrdersListViewControllerComponent->BookmarkedWorkOrdersContainerViewControllerComponent->OfflineTableSourceComponent->LocationContextMenuListComponent how would I go about reading and resolving it?

@apstygo
Copy link

apstygo commented Dec 27, 2022

I've run into the same problem, though for me the cycle is even shorter. I am developing an app for viewing images on image boards. An image's page contains links to other images. This means that logically PostDetailComponent can create and become a parent of another PostDetailComponent, which makes sense and does indeed create a cycle.

Cycles such as this are common and I remember a time when Needle did not complain about them. This seems to have changed in the past couple of versions.

@rudro your comments on the subject would be greatly appreciated.

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