All Projects → AndreyPanov → Applicationcoordinator

AndreyPanov / Applicationcoordinator

Licence: mit
Coordinators Essential tutorial

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Applicationcoordinator

Archit Ios
Intelygenz iOS Architecture
Stars: ✭ 203 (-70.75%)
Mutual labels:  protocols, architecture
Onboarding
A list of resources we at flyeralarm use to get new developers up and running
Stars: ✭ 648 (-6.63%)
Mutual labels:  architecture
Reference Architectures
templates and scripts for deploying Azure Reference Architectures
Stars: ✭ 554 (-20.17%)
Mutual labels:  architecture
Emba
emba - An analyzer for Linux-based firmware of embedded devices.
Stars: ✭ 607 (-12.54%)
Mutual labels:  architecture
React Best Practices
A comprehensive reference guide to kickstart your React architecting career!
Stars: ✭ 566 (-18.44%)
Mutual labels:  architecture
Impress
Enterprise application server for Node.js and Metarhia private cloud ⚡
Stars: ✭ 634 (-8.65%)
Mutual labels:  architecture
Pluggableapplicationdelegate
Smallest AppDelegate ever by using a decoupled-services based architecture. 🛠
Stars: ✭ 536 (-22.77%)
Mutual labels:  architecture
Arkit
JavaScript architecture diagrams and dependency graphs
Stars: ✭ 671 (-3.31%)
Mutual labels:  architecture
Mosby
A Model-View-Presenter / Model-View-Intent library for modern Android apps
Stars: ✭ 5,473 (+688.62%)
Mutual labels:  architecture
Netzob
Netzob: Protocol Reverse Engineering, Modeling and Fuzzing
Stars: ✭ 584 (-15.85%)
Mutual labels:  protocols
Coca
Coca is a toolbox which is design for legacy system refactoring and analysis, includes call graph, concept analysis, api tree, design patterns suggest. Coca 是一个用于系统重构、系统迁移和系统分析的瑞士军刀。它可以分析代码中的测试坏味道、模块化分析、行数统计、分析调用与依赖、Git 分析以及自动化重构等。
Stars: ✭ 576 (-17%)
Mutual labels:  architecture
Ios Developer Roadmap
Roadmap to becoming an iOS developer in 2018.
Stars: ✭ 5,514 (+694.52%)
Mutual labels:  architecture
Thecontext Podcast
Podcast about Android Development with Hannes Dorfmann, Artem Zinnatullin, Artur Dryomov and wonderful guests!
Stars: ✭ 637 (-8.21%)
Mutual labels:  architecture
Angular Architecture
Examples of Angular Architecture Concepts
Stars: ✭ 556 (-19.88%)
Mutual labels:  architecture
Architectureplaybook
The Open Architecture Playbook. Use it to create better and faster (IT)Architectures. OSS Tools, templates and more for solving IT problems using real open architecture tools that work!
Stars: ✭ 652 (-6.05%)
Mutual labels:  architecture
Nsmartproxy
NSmartProxy是一款开源免费的内网穿透工具。采用.NET CORE的全异步模式打造。(NSmartProxy is an open source reverse proxy tool that creates a secure tunnel from a public endpoint to a locally service.)
Stars: ✭ 547 (-21.18%)
Mutual labels:  protocols
Combinefeedback
Unidirectional reactive architecture using new Apple Combine framework https://developer.apple.com/documentation/combine
Stars: ✭ 571 (-17.72%)
Mutual labels:  architecture
Coordinator
Implementation of Coordinators app design pattern.
Stars: ✭ 616 (-11.24%)
Mutual labels:  architecture
Apk Dependency Graph
Android class dependency visualizer. This tool helps to visualize the current state of the project.
Stars: ✭ 675 (-2.74%)
Mutual labels:  architecture
System design
Preparation links and resources for system design questions
Stars: ✭ 7,170 (+933.14%)
Mutual labels:  architecture

ApplicationCoordinator

A lot of developers need to change navigation flow frequently, because it depends on business tasks. And they spend a huge amount of time for re-writing code. In this approach, I demonstrate our implementation of Coordinators, the creation of a protocol-oriented, testable architecture written on pure Swift without the downcast and, also to avoid the violation of the S.O.L.I.D. principles.

Based on the post about Application Coordinators khanlou.com and Application Controller pattern description martinfowler.com.

Coordinators Essential tutorial. Part I medium.com

Coordinators Essential tutorial. Part II medium.com

Example provides very basic structure with 6 controllers and 5 coordinators with mock data and logic.

I used a protocol for coordinators in this example:

protocol Coordinator: class {
    func start()
    func start(with option: DeepLinkOption?)
}

All flow controllers have a protocols (we need to configure blocks and handle callbacks in coordinators):

protocol ItemsListView: BaseView {
    var authNeed: (() -> ())? { get set }
    var onItemSelect: (ItemList -> ())? { get set }
    var onCreateButtonTap: (() -> ())? { get set }
}

In this example I use factories for creating coordinators and controllers (we can mock them in tests).

protocol CoordinatorFactory {
    func makeItemCoordinator(navController navController: UINavigationController?) -> Coordinator
    func makeItemCoordinator() -> Coordinator
    
    func makeItemCreationCoordinatorBox(navController: UINavigationController?) ->
        (configurator: Coordinator & ItemCreateCoordinatorOutput,
        toPresent: Presentable?)
}

The base coordinator stores dependencies of child coordinators

class BaseCoordinator: Coordinator {
    
    var childCoordinators: [Coordinator] = []

    func start() { }
    func start(with option: DeepLinkOption?) { }
    
    // add only unique object
    func addDependency(_ coordinator: Coordinator) {
        
        for element in childCoordinators {
            if element === coordinator { return }
        }
        childCoordinators.append(coordinator)
    }
    
    func removeDependency(_ coordinator: Coordinator?) {
        guard
            childCoordinators.isEmpty == false,
            let coordinator = coordinator
            else { return }
        
        for (index, element) in childCoordinators.enumerated() {
            if element === coordinator {
                childCoordinators.remove(at: index)
                break
            }
        }
    }
}

AppDelegate store lazy reference for the Application Coordinator

var rootController: UINavigationController {
    return self.window!.rootViewController as! UINavigationController
  }
  
  private lazy var applicationCoordinator: Coordinator = self.makeCoordinator()
  
  func application(_ application: UIApplication,
                   didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let notification = launchOptions?[.remoteNotification] as? [String: AnyObject]
    let deepLink = DeepLinkOption.build(with: notification)
    applicationCoordinator.start(with: deepLink)
    return true
  }
  
  private func makeCoordinator() -> Coordinator {
      return ApplicationCoordinator(
        router: RouterImp(rootController: self.rootController),
        coordinatorFactory: CoordinatorFactoryImp()
      )
  }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].