All Projects → fmo91 → Pluggableapplicationdelegate

fmo91 / Pluggableapplicationdelegate

Licence: mit
Smallest AppDelegate ever by using a decoupled-services based architecture. 🛠

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Pluggableapplicationdelegate

ddd-example-ecommerce
Domain-driven design example in Java with Spring framework
Stars: ✭ 73 (-86.38%)
Mutual labels:  services, architecture
Complex Redux Project Architecture
Redux architecture extended with a layer of services.
Stars: ✭ 53 (-90.11%)
Mutual labels:  services, architecture
Dephpend
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...
Stars: ✭ 449 (-16.23%)
Mutual labels:  architecture
3rs Of Software Architecture
A guide on how to write readable, reusable, and refactorable software
Stars: ✭ 525 (-2.05%)
Mutual labels:  architecture
Android Showcase
💎 Android application following best practices: Kotlin, Coroutines, JetPack, Clean Architecture, Feature Modules, Tests, MVVM, DI, Static Analysis...
Stars: ✭ 5,214 (+872.76%)
Mutual labels:  architecture
Cola
🥤 COLA: Clean Object-oriented & Layered Architecture
Stars: ✭ 6,186 (+1054.1%)
Mutual labels:  architecture
Modular Monolith With Ddd
Full Modular Monolith application with Domain-Driven Design approach.
Stars: ✭ 6,210 (+1058.58%)
Mutual labels:  architecture
Awesome Ios Architecture
🏯 Better ways to structure iOS apps
Stars: ✭ 4,451 (+730.41%)
Mutual labels:  architecture
Awesome Fenix
讨论如何构筑一套可靠的分布式大型软件系统
Stars: ✭ 530 (-1.12%)
Mutual labels:  architecture
Designpatternslibrary
A comprehensive design patterns library implemented in C#, which covers various design patterns from the most commonly used ones to the lesser-known ones. Get familiar with and learn design patterns through moderately realistic examples.
Stars: ✭ 485 (-9.51%)
Mutual labels:  architecture
Awaker
article app for android
Stars: ✭ 526 (-1.87%)
Mutual labels:  architecture
Viabus Architecture
让 Android 开发可以像流水线一样高效的,职责分离架构 ⚡ 不同于 MVP 的配置解耦,也不能和 似是而非 的 MVVM - Clean 同日而语。VIABUS 是世界范围内首个明确提出,通过职责分离,来真正实现 UI 和 业务并行开发的 Android 项目级开发架构和设计模式理念。
Stars: ✭ 485 (-9.51%)
Mutual labels:  architecture
Coordinator Mvvm Rx Example
Example of MVVM-C architecture implemented with RxSwift
Stars: ✭ 469 (-12.5%)
Mutual labels:  architecture
Enterprise Scale
The Enterprise-Scale architecture provides prescriptive guidance coupled with Azure best practices, and it follows design principles across the critical design areas for organizations to define their Azure architecture
Stars: ✭ 511 (-4.66%)
Mutual labels:  architecture
Fullstack Javascript Architecture
✍️ Opinionated project architecture for Full-Stack JavaScript Applications.
Stars: ✭ 464 (-13.43%)
Mutual labels:  architecture
Swift Viper Module
Xcode template for VIPER Architecture written in Swift 4
Stars: ✭ 527 (-1.68%)
Mutual labels:  architecture
Iosched
The Google I/O Android App
Stars: ✭ 20,991 (+3816.23%)
Mutual labels:  architecture
Moduliths
Building modular, monolithic applications using Spring Boot
Stars: ✭ 478 (-10.82%)
Mutual labels:  architecture
Equinoxproject
Full ASP.NET Core 5 application with DDD, CQRS and Event Sourcing concepts
Stars: ✭ 5,120 (+855.22%)
Mutual labels:  architecture
Blackviperscript
Sets Win 10 Services based on Black Viper's Service Configurations
Stars: ✭ 536 (+0%)
Mutual labels:  services

PluggableApplicationDelegate

CI Status Version License Platform

Introduction

AppDelegate is a traditional example of bad code. Lots of line of code that makes so much different things are put together in methods that are called within the application life cycle. But all of those concerns are over. Using PluggableApplicationDelegate you decouple AppDelegate from the services that you plug to it. Each ApplicationService has its own life cycle that is shared with AppDelegate.

At a glance

Let see some code. Here is how a ApplicationService is like:

import Foundation
import PluggableApplicationDelegate

final class LoggerApplicationService: NSObject, ApplicationService {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
        
        print("It has started!")
        
        return true
    }
    
    func applicationDidEnterBackground(_ application: UIApplication) {
        print("It has entered background")
    }
}

That's all. It is exactly the same as a AppDelegate. Think of ApplicationService as sub-AppDelegates.

In AppDelegate you just have to inherit from PluggableApplicationDelegate to register the services.

import UIKit
import PluggableApplicationDelegate

@UIApplicationMain
class AppDelegate: PluggableApplicationDelegate {
    
    override var services: [ApplicationService] {
        return [
            LoggerApplicationService()
        ]
    }
}

Yes. That's all. Simple.

How does this work?

You may want to read my Medium post about Pluggable App Delegate. Basically, you do an inversion of control. Instead of let AppDelegate instantiate your dependencies, perform actions at every step of its life cycle, you create objects that share the AppDelegate life cycle and plug them into your AppDelegate. Those objects are observers of the AppDelegate. Your AppDelegate has the only responsibility of notify them about its life cycle events.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

PluggableApplicationDelegate requires Swift 3.0 or above.

Installation

PluggableApplicationDelegate is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PluggableApplicationDelegate'

Author

fmo91, [email protected]

License

PluggableApplicationDelegate is available under the MIT license. See the LICENSE file for more info.

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].