Latest 1.0.0
Homepage https://github.com/Michael-Vorontsov/DependencyManager
License MIT
Platforms ios 10.0
Authors

CI Status
Version
License
Platform

DependencyManager provides simple interface for declaring weak dependencies. Weak means that dependencies will live in memory as long as some other part of app keep using it, and will autoreleased when it’s no longer needed, reducing memory footprint.

DepedencyManager itself provides ability to retrieve/create new services by keys using swift resolve<T>(key: String, creator: () -> (T)) function by unique key for services and creator block that should be called when services had to be recreated.

Generally it is recommended to describe public interface to intended services as Protocol then, then provide implementation as private class conforming to the protocol and in that same file declare extension to DependencyManagerProtocol to create specific implementation as the protocol:


 protocol FetchStringsServiceProtocol: PublicServicePorotocol {
    func fetchStrings(handler:  (([String]) -> () ) )
 }

 extension DependencyManagerProtocol {
    func resolveFetchStringsService() -> FetchServiceProtocol {
        return self.resolve(key: "StringService") {
            StringServiceImp(...)
        }
    }
 }

 private class StringServiceImp: FetchStringsServiceProtocol {

    func fetchStrings(handler:  (([String]) -> () ) ) {
        ...
    }
 }

Please see Expample for additional details.

Example

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

Requirements

Framework compliant with Swift4.2 and by so require XCode10.

Installation

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

pod 'DependencyManager'

Or via Carthage

github "Michael-Vorontsov/DependencyManager"

Author

Michael Vorontsov, [email protected]

License

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

Latest podspec

{
    "name": "DependencyManager",
    "version": "1.0.0",
    "summary": "Simple DependencyManager.",
    "swift_version": "4.2",
    "description": "DependencyManager provides simple way to manage dependencies accors app,nInitialise it on demand in release if when no longer needed.",
    "homepage": "https://github.com/Michael-Vorontsov/DependencyManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Michael Vorontsov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Michael-Vorontsov/DependencyManager.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "DependencyManager/Classes/**/*"
}

Pin It on Pinterest

Share This