Coder Social home page Coder Social logo

Comments (3)

basememara avatar basememara commented on July 23, 2024

More Swifty router implemented in PR #25. Instead of segues, use the extended show API with completion handler for configuring target view controller:

class ListOrdersRouter: NSObject, RouterProtocol,...
{
  func routeToShowOrder(for id: String)
  {
    show(storyboard: .showOrder) { (destinationVC: ShowOrderViewController) in
      let selectedOrder = self.dataStore?.orders?.first { $0.id == id }
      var destinationDS = destinationVC.router!.dataStore!
      self.passDataToShowOrder(for: selectedOrder, destination: &destinationDS)
    }
  }
  
  func routeToCreateOrder()
  {
    show(storyboard: .createOrder) { (destinationVC: CreateOrderViewController) in
      var destinationDS = destinationVC.router!.dataStore!
      self.passDataToCreateOrder(source: self.dataStore!, destination: &destinationDS)
    }
  }

Also, each scene has its own storyboard instead of placed all in one main storyboard:

capturfiles_16

Let me know what you think.

from cleanstore.

crashoverride777 avatar crashoverride777 commented on July 23, 2024

Hey, the changes are very nice. Separate storyboards for each unique scene is the way to go. However the router class itself is still not swifty. Swift is a protocol and extension orientated language, so having a class with 2 methods and a weak property to the VC is clunky. It’s also a memory leaker if weak is forgot as the VC is also referencing the rooter class. That whole class for example could easily just be a extension of the view controller, optionally in a new swift file. I am just pointing this out as I feel clean architecture is outdated for Swift, especially they way most tutorials and the cleanSwift website do it. Thanks for your detailed reply and your awesome repo.

from cleanstore.

basememara avatar basememara commented on July 23, 2024

Cool thx for taking a look and the feedback. I definitely agree with all your points.

I have another repo called stateless_arch where all parts are value-type structs instead of classes. My thought is the architectural flow should be stateless and immutable, with the exception of the view controller of course. That should be safer, simpler to think about, and in the spirit of Swift philosophy. It’s a bit of work so still chipping away at it.

from cleanstore.

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.