Skip to content

DMInject is a Dependency Manager that helps you to clear your code and be more productive.

License

Notifications You must be signed in to change notification settings

narlei/DMInject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DMInject

Version License Platform

DMInject is a Dependency Manager that helps you to clear your code and be more productive.

Example

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

How to use

First Step - add mapping:

import DMInject

class DMInjectionMapper: DMInjectionMapperProtocol {
    var arrayReturn = [Any]()

    // Use this map to add the objects, the DMInject will get by type
    func initialize() {
        arrayReturn.append(MyClass())
    }

    func getAllInjections() -> [Any] {
        return arrayReturn
    }
}

Add to your AppDelegate:

DMInject.main.initialize(mapper: DMInjectionMapper())

Now is only use:

// Exemple 1: Easy way
var myclass: MyClassProtocol?
myclass << DMInject()
if let name = myclass?.getName() {
    print(name)
}


// Exemple 2: Declarative way
let myClass2 = DMInject.main.getInstance(interface: MyClassProtocol.self)
if let name = myClass2?.getName() {
    print(name)
}

// Example 3: Using Property Wraper
@Inject
var myClassX: MyClassProtocol?

Requirements

  • iOS 9.3
  • XCode 11

Installation

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

pod 'DMInject'

Author

Narlei Moreira, [email protected]

License

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

About

DMInject is a Dependency Manager that helps you to clear your code and be more productive.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published