Giter Site home page Giter Site logo

biodag's Introduction

Biodag Build Status

Biodag: [pit̪akˈ] - dirk in Scottish Gaelic, a long thrusting dagger.

A Swift micro-library that provides lightweight dependency injection, heavily influenced by Shank

Inject dependencies via property wrappers:

final class ViewController: UIViewController {
    
    @Inject private var widgetModule: WidgetModuleType
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        widgetModule.test()
    }
}

Register modules early in your app:

class AppDelegate: UIResponder, UIApplicationDelegate {

    private let dependencies = Dependencies {
        // A prototype dependency (i.e. one per @Inject)
        Module { WidgetModule() as WidgetModuleType }
        // A dependency that's scoped to be a singleton
        Module(scope: .singleton) { SingletonModule() as SingletonModuleType }
    }
    
    override init() {
        super.init()
        dependencies.build()
    }
}

If you forget to build the dependency container, it will result in a run-time exception.

Installation

The easiest way to install this is via CocoaPods:

pod 'Biodag', '~> 0.2.0'

You can also use SPM. Add a dependency for Biodag like:

.package(url: "https://github.com/kerrmarin/biodag.git", from: "0.2.0")

Contributing

To run the tests, run swift test.

To open in Xcode, open the package workspace file inside the .swiftpm/xcode folder.

If you find a bug or want to suggest an improvement, open an issue and, optionally (but encouraged!), make a PR :)

biodag's People

Contributors

kerrmarin avatar basememara avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.