Latest 0.2.0
Homepage https://github.com/threeplay/TPInjector
License MIT
Platforms osx 10.10
Authors

CI Status
Version
License
Platform

Usage

To setup dependencies you set or register them on the DefaultInjector

  DefaultInjector.set(key: "api_key", to: "12345678")
  DefaultInjector.set(key: "api_url", to: NSURL(string: "https://someurl.com"))
  DefaultInjector.register(service: NetworkService.self, with: NetworkServiceImpl())
  DefaultInjector.register(service: LoginService.self, with: LoginServiceImpl())

To inject dependecies you add Injectable protocol to your class/struct definition and inject / tryInject static methods to inject dependencies:

class ClassWithDependecies: Injectable {

  private let networkService = inject(NetworkService.self)
  private let api_key = inject("api_key", String.self)
  private let api_url: NSURL = tryInject("api_url") ?? NSURL(string: "https://default.com")

  init(loginService: LoginService = inject()) {

  }
}

Example

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

Installation

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

pod 'TPInjector'

Author

Eliran Ben-Ezra, [email protected]

License

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

Latest podspec

{
    "name": "TPInjector",
    "version": "0.2.0",
    "summary": "Swift dependency injection",
    "description": "Simple swift dependency injection framework",
    "homepage": "https://github.com/threeplay/TPInjector",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Eliran Ben-Ezra": "[email protected]"
    },
    "source": {
        "git": "https://github.com/threeplay/TPInjector.git",
        "tag": "0.2.0"
    },
    "swift_version": "4.0",
    "platforms": {
        "osx": "10.10"
    },
    "source_files": "TPInjector/Classes/**/*"
}

Pin It on Pinterest

Share This