-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c7355e3
Showing
13 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata |
8 changes: 8 additions & 0 deletions
8
.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// swift-tools-version:5.5 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Core", | ||
platforms: [.iOS(.v15), .macOS(.v12)], | ||
products: [ | ||
// Products define the executables and libraries a package produces, and make them visible to other packages. | ||
.library( | ||
name: "Core", | ||
targets: ["Core"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages this package depends on. | ||
.target( | ||
name: "Core", | ||
dependencies: []), | ||
.testTarget( | ||
name: "CoreTests", | ||
dependencies: ["Core"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Core | ||
|
||
A description of this package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 03/12/21. | ||
// | ||
|
||
import Combine | ||
|
||
public protocol LocaleDataSource { | ||
associatedtype Request | ||
associatedtype Response | ||
|
||
func getAllList(request: Request?) -> AnyPublisher<[Response], Error> | ||
|
||
func getById(_ id: Int) -> AnyPublisher<Response, Error> | ||
|
||
func set(_ entity: Response) -> AnyPublisher<Bool, Error> | ||
|
||
func deleteAll(request: Request?) -> AnyPublisher<Bool, Error> | ||
|
||
func deleteById(_ id: Int) -> AnyPublisher<Bool, Error> | ||
|
||
func loadUserDefault() -> AnyPublisher<Response, Error> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 09/12/21. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol LocaleMapper { | ||
associatedtype Entity | ||
associatedtype Domain | ||
|
||
func transformEntityToDomain(entity: Entity) -> Domain | ||
func transfomDomainToEntity(domain: Domain) -> Entity | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 06/12/21. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol Mapper { | ||
associatedtype Response | ||
associatedtype Domain | ||
|
||
func transfomResponseToDomain(response: Response) -> Domain | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 03/12/21. | ||
// | ||
|
||
import Combine | ||
|
||
public protocol RemoteDataSource { | ||
associatedtype Request | ||
associatedtype Response | ||
|
||
func execute(request: Request?) -> AnyPublisher<Response, Error> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 03/12/21. | ||
// | ||
|
||
import Combine | ||
|
||
public protocol Repository { | ||
associatedtype Request | ||
associatedtype Response | ||
|
||
func execute(request: Request?) -> AnyPublisher<Response, Error> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 03/12/21. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
|
||
public struct Interactor<Request, Response, R: Repository>: UseCase | ||
where R.Request == Request, R.Response == Response { | ||
|
||
private let _repository: R | ||
|
||
public init(repository: R) { | ||
_repository = repository | ||
} | ||
|
||
public func execute(request: Request?) -> AnyPublisher<Response, Error> { | ||
_repository.execute(request: request) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 03/12/21. | ||
// | ||
|
||
import Combine | ||
|
||
public protocol UseCase { | ||
associatedtype Request | ||
associatedtype Response | ||
|
||
func execute(request: Request?) -> AnyPublisher<Response, Error> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alfa Centaury on 08/12/21. | ||
// | ||
|
||
import Combine | ||
import Foundation | ||
|
||
public class GetPresenter<Request, Response, Interactor: UseCase> | ||
where Interactor.Request == Request, Interactor.Response == Response { | ||
|
||
private var cancellables: Set<AnyCancellable> = [] | ||
private let _useCase: Interactor | ||
|
||
public init(useCase: Interactor) { | ||
_useCase = useCase | ||
} | ||
|
||
public func getPresenter(request: Request?, | ||
receiveCompletion: @escaping (Subscribers.Completion<Error>) -> Void, | ||
receiveValue: @escaping (Response) -> Void) { | ||
_useCase.execute(request: request) | ||
.receive(on: RunLoop.main) | ||
.sink(receiveCompletion: { completion in | ||
receiveCompletion(completion) | ||
}, | ||
receiveValue: { result in | ||
receiveValue(result) | ||
}) | ||
.store(in: &cancellables) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import XCTest | ||
@testable import Core | ||
|
||
final class CoreTests: XCTestCase { | ||
func testExample() throws { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct | ||
// results. | ||
XCTAssertEqual(Core().text, "Hello, World!") | ||
} | ||
} |