Giter VIP home page Giter VIP logo

Comments (2)

radianttap avatar radianttap commented on June 16, 2024 1

It's not that simple, sadly.

If parentCoordinator has, say 2 child Coordinators, and second one is popped, maybe the 1st child should take ownership, not the parent. And maybe not, it really depends on the app.
(Only if no child Coordinators are left then parent Coordinator should take ownership.)
This is related to #10 and same as there – I don't see a straight-forward solution that works in all cases.

Coordinator is deliberatelly made simple to cover just the basics. Dealing with logic like this is something that app should decide in its own subclass of NavigationCoordinator – only in the context of the specific app a decision can be made what should happen is particular Coordinator instance is stopped.

Example for the shop app I used as demo: say

  • You are on CatalogCoordinator and want to buy something
  • You tap on Buy now
  • This is routed up to the CatalogCoordinator which then checks with AccountManager are you logged in
  • If not, it pushes AccountCoordinator to show LoginVC
  • When login is done, it could return you to CatalogCoordinator and you tap Buy now again but...
  • it's better if it would just continue the flow and push PaymentCoordinator

That's why I don't think this is something that library should decide on its own – it's app developer's job.

from coordinator.

MarcSteven avatar MarcSteven commented on June 16, 2024

Compared with the code ,add the judgement logic here .I think it's a great design to reduce the bugs.We should know when we must relinquish the delegate completely ,so that's the difference between the code. @radianttap Thank for your sharing and contribution ....

open override func stop(with completion: @escaping () -> Void) {
			rootViewController.delegate = nil

			for vc in viewControllers {
			guard let index = rootViewController.viewControllers.index(of: vc) else { continue }
			rootViewController.viewControllers.remove(at: index)
		}
		viewControllers.removeAll()
		super.stop(with: completion)
	} 

from coordinator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.