Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Pure Native

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# SwiftDI

A description of this package.
Lightweight dependency injection library.

## Requirements

- Swift 5.5 or newer
- iOS 11.0 or newer

## Installation

You can install this package using [Swift Package Manager](https://www.swift.org/package-manager/) by adding the following line to the `dependencies` in your `Package.swift` file:

```swift
.package(url: "https://github.com/purenative/SwiftDI.git", .branch("main"))
```

## Contributing

Don't forget to open an issue if you found a bug or have a question. Feel free to fork this repository and open a pull request if you fixed an existing feature or implemented a new one.

## License

SwiftDI is released under the MIT license. See LICENSE for details.
11 changes: 11 additions & 0 deletions Sources/SwiftDI/Private/DIContainerStorage.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// DIContainerStorage.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

final class DIContainerStorage<OP: DIObjectProvider> {

private var providers = [DIEntityTypeKey: OP]()
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftDI/Private/DIEntityTypeKey.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// DIEntityTypeKey.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

final class DIEntityTypeKey: Hashable {

let entityName: String
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftDI/Private/DIFabricObjectProvider.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// DIFabricObjectProvider.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

final class DIFabricObjectProvider: DIObjectProvider {

static var scope: DIObjectScope {
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftDI/Private/DIInstanceObjectProvider.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// DIInstanceObjectProvider.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

final class DIInstanceObjectProvider: DIObjectProvider {

private var _instance: Any!
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftDI/Private/DIObjectProvider.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// DIObjectProvider.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

protocol DIObjectProvider {

static var scope: DIObjectScope { get }
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftDI/Public/DIContainer.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// DIContainer.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

public class DIContainer {

private let fabricStorage = DIContainerStorage<DIFabricObjectProvider>()
Expand Down
11 changes: 11 additions & 0 deletions Sources/SwiftDI/Public/DIObjectScope.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//
// DIObjectScope.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import Foundation

public enum DIObjectScope: String {

case fabric
Expand Down
9 changes: 9 additions & 0 deletions Tests/SwiftDITests/SwiftDITests.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
//
// SwiftDITests.swift
// SwiftDI
//
// MIT License
//
// Copyright (c) 2022 Pure Native
//

import XCTest
@testable import SwiftDI

Expand Down