DMInject 0.1.3

DMInject 0.1.3

Maintained by Narlei Moreira.



DMInject 0.1.3

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.