-
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
yutu
committed
Mar 22, 2018
1 parent
337f4a1
commit 153465b
Showing
7 changed files
with
150 additions
and
11 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
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,21 @@ | ||
// | ||
// ApplicationAssembly.swift | ||
// ReSwiftFeedSample | ||
// | ||
// Created by Yuki Hirai on 2018/03/22. | ||
// Copyright © 2018年 Recruit Marketing Partners Co., Ltd. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Swinject | ||
|
||
struct ApplicationAssembly: Assembly { | ||
func assemble(container: Container) { | ||
container.register(AppStore.self) { _ in | ||
AppStore( | ||
reducer: appReducer, | ||
state: nil | ||
) | ||
}.inObjectScope(.container) | ||
} | ||
} |
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,28 @@ | ||
// | ||
// ContainerProvider.swift | ||
// ReSwiftFeedSample | ||
// | ||
// Created by Yuki Hirai on 2018/03/22. | ||
// Copyright © 2018年 Recruit Marketing Partners Co., Ltd. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Swinject | ||
|
||
struct ContainerProvider { | ||
static var `default`: Container = createDefaultContainer | ||
|
||
private static var createDefaultContainer: Container { | ||
let container = Container() | ||
assemblies.forEach { $0.assemble(container: container) } | ||
return container | ||
} | ||
|
||
private static var assemblies: [Assembly] { | ||
return [ | ||
PresentationAssembly(), | ||
ApplicationAssembly(), | ||
InfrastructureAssembly() | ||
] | ||
} | ||
} |
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 @@ | ||
// | ||
// InfrastructureAssembly.swift | ||
// ReSwiftFeedSample | ||
// | ||
// Created by Yuki Hirai on 2018/03/22. | ||
// Copyright © 2018年 Recruit Marketing Partners Co., Ltd. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import APIKit | ||
import Swinject | ||
|
||
// swiftlint:disable force_unwrapping | ||
|
||
struct InfrastructureAssembly: Assembly { | ||
func assemble(container: Container) { | ||
container.register(PostRepository.self) { r in | ||
PostNetworkingRepository(session: r.resolve(APIKit.Session.self)!) | ||
} | ||
|
||
container.register(APIKit.Session.self) { r in | ||
APIKit.Session(adapter: r.resolve(URLSessionAdapter.self)!) | ||
} | ||
|
||
container.register(URLSessionAdapter.self) { _ in | ||
URLSessionAdapter(configuration: URLSessionConfiguration.default) | ||
} | ||
} | ||
} |
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,22 @@ | ||
// | ||
// PresentationAssembly.swift | ||
// ReSwiftFeedSample | ||
// | ||
// Created by Yuki Hirai on 2018/03/22. | ||
// Copyright © 2018年 Recruit Marketing Partners Co., Ltd. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Swinject | ||
import SwinjectStoryboard | ||
|
||
// swiftlint:disable force_unwrapping | ||
|
||
struct PresentationAssembly: Assembly { | ||
func assemble(container: Container) { | ||
container.storyboardInitCompleted(FeedViewController.self) { r, c in | ||
c.store = r.resolve(AppStore.self)! | ||
c.load = ShowFeed.load(postRepository: r.resolve(PostRepository.self)!) | ||
} | ||
} | ||
} |
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,17 @@ | ||
// | ||
// SwinjectStoryboard+Setup.swift | ||
// ReSwiftFeedSample | ||
// | ||
// Created by Yuki Hirai on 2018/03/22. | ||
// Copyright © 2018年 Recruit Marketing Partners Co., Ltd. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Swinject | ||
import SwinjectStoryboard | ||
|
||
extension SwinjectStoryboard { | ||
@objc class func setup() { | ||
defaultContainer = ContainerProvider.default | ||
} | ||
} |
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