{"id":23152463,"url":"https://github.com/1amageek/injectable","last_synced_at":"2025-08-17T20:32:55.968Z","repository":{"id":56915516,"uuid":"105499152","full_name":"1amageek/Injectable","owner":"1amageek","description":"Dependency Injection for Swift","archived":false,"fork":false,"pushed_at":"2017-10-02T06:08:16.000Z","size":109,"stargazers_count":31,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-24T16:42:49.536Z","etag":null,"topics":["dependency","dependency-injection","inject","injection","swift"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1amageek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-02T04:49:33.000Z","updated_at":"2023-03-14T12:09:20.000Z","dependencies_parsed_at":"2022-08-21T02:50:39.622Z","dependency_job_id":null,"html_url":"https://github.com/1amageek/Injectable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2FInjectable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2FInjectable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2FInjectable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1amageek%2FInjectable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1amageek","download_url":"https://codeload.github.com/1amageek/Injectable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230167887,"owners_count":18183846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency","dependency-injection","inject","injection","swift"],"created_at":"2024-12-17T19:14:48.268Z","updated_at":"2024-12-17T19:14:48.965Z","avatar_url":"https://github.com/1amageek.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"text-align: center; width: 100%\"\u003e\n\u003cimg src=\"https://github.com/1amageek/Injectable/blob/master/Injectable.png\", width=\"80%\"\u003e\n\n\n[![Version](http://img.shields.io/cocoapods/v/Injectable.svg)](http://cocoapods.org/?q=Injectable)\n[![Platform](http://img.shields.io/cocoapods/p/Injectable.svg)](http://cocoapods.org/?q=Injectable)\n[![Downloads](https://img.shields.io/cocoapods/dt/Injectable.svg?label=Total%20Downloads\u0026colorB=28B9FE)](https://cocoapods.org/pods/Injectable)\n\u003c/div\u003e\n\n# Injectable\n\nDependency Injection for Swift.\n\nThe dependency injection pattern leads to code that's modular and testable, and Guice makes it easy to write. \n\n[Google Guice](https://github.com/google/guice/wiki/Motivation)\n\n## Installation\n\n```\npod 'Injectable'\n```\n\n## Usage\n\n``` swift\n// ViewController.swift\nclass ViewController: UIViewController {\n\n    @IBAction func show(_ sender: Any) {\n        let viewController: InjectableViewController = InjectableViewController(with: .init(color: .green))\n        self.present(viewController, animated: true, completion: nil)\n    }\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n    }\n}\n```\n\n``` swift\n// InjectableViewController.swift\nprotocol Colorable: Injectable {\n    init(with dependency: Dependency)\n}\n\nclass InjectableViewController: UIViewController, Colorable {\n\n    required init(with dependency: InjectableViewController.Dependency) {\n        super.init(nibName: nil, bundle: nil)\n        self.inject(dependency)\n    }\n\n    required init?(coder aDecoder: NSCoder) {\n        fatalError(\"init(coder:) has not been implemented\")\n    }\n\n    struct Dependency {\n        var color: UIColor\n    }\n\n    func inject(_ dependency: InjectableViewController.Dependency) {\n        self.view.backgroundColor = dependency.color\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1amageek%2Finjectable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1amageek%2Finjectable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1amageek%2Finjectable/lists"}