This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Showing
56 changed files
with
1,306 additions
and
627 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,48 +1,15 @@ | ||
// | ||
// RootComponent.swift | ||
// Component.swift | ||
// Cleanse | ||
// | ||
// Created by Mike Lewis on 5/2/16. | ||
// Created by Mike Lewis on 7/6/16. | ||
// Copyright © 2016 Square, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Used to detect if things being bound are a component. | ||
/// Un-typed base protocol of component. Probably shouldn't be used directly | ||
public protocol _AnyRootComponent : _AnyBaseComponent { | ||
} | ||
|
||
|
||
/// RootComponent has been renamed to RootComponent | ||
#if swift(>=3.0) | ||
@available(*, deprecated, renamed:"RootComponent") | ||
public typealias Component = RootComponent | ||
#else | ||
@available(*, deprecated, renamed="RootComponent") | ||
public typealias Component = RootComponent | ||
#endif | ||
|
||
public protocol RootComponent : Module, _BaseComponent, _AnyRootComponent { | ||
/// This should be set to the root type of object that is created. | ||
associatedtype Root | ||
|
||
associatedtype Scope = Singleton | ||
public protocol Component : _BaseComponent { | ||
/// can have custom scopes associated with them. | ||
associatedtype Scope = _Unscoped | ||
} | ||
|
||
public extension RootComponent { | ||
/// Builds the component and returns the root object. | ||
/// - throws: `CleanseError` if the component fails validation. | ||
public func build() throws -> Root { | ||
let graph = Graph(scope: Self.Scope.scopeOrNil) | ||
|
||
let p = graph.provider(Root.self) | ||
|
||
graph.install(module: self) | ||
|
||
try graph.finalize() | ||
|
||
return p.get() | ||
} | ||
} | ||
|
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
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
Oops, something went wrong.