-
Couldn't load subscription status.
- Fork 14
Container
A container from which services should be registered and resolved.
public final class ContainerInitialize a container with an optional parent Container.
public init(parent: Container? = nil)- parent: The optional parent
Container. Defaults tonil.
A global, singleton container.
var globalRegister a transient service to this container. Transient means that it's factory closure will be called each time the service type is resolved.
public func register<T>(_ service: T.Type, factory: @escaping (Container) -> T)- service: The type of the service to register.
- factory: The closure for instantiating an instance of the service.
Register a singleton service to this container. This means that it's factory closure will be called once and that value will be returned each time the service is resolved.
public func register<S>(singleton service: S.Type, factory: @escaping (Container) -> S)- service: The type of the service to register.
- factory: The closure for instantiating an instance of the service.
Register a identified singleton service to this container. Singleton means that it's factory closure will be called once per unique identifier and that value will be returned each time the service is resolved.
public func register<S, H: Hashable>(singleton service: S.Type, identifier: H, factory: @escaping (Container) -> S)- service: The type of the service to register.
- factory: The closure for instantiating an instance of the service.
Resolves a service, returning an instance of it, if one is registered.
public func resolveOptional<T>(_ service: T.Type) -> T?- service: The type of the service to resolve.
An instance of the service.
Resolves a service with the given identifier, returning an
instance of it if one is registered.
public func resolveOptional<T, H: Hashable>(_ service: T.Type, identifier: H?) -> T?- service: The type of the service to resolve.
- identifier: The identifier of the service to resolve.
An instance of the service.
Resolves a service, returning an instance of it.
public func resolve<T>(_ service: T.Type) -> TThis will fatalError if the service isn't registered.
- service: The type of the service to resolve.
An instance of the service.
Resolves a service with the given identifier, returning an
instance of it.
public func resolve<T, H: Hashable>(_ service: T.Type, identifier: H?) -> TThis will fatalError if the service isn't registered.
- service: The type of the service to resolve.
- identifier: The identifier of the service to resolve.
An instance of the service.
Generated at 2021-01-13T22:24:59-0800 using swift-doc 1.0.0-beta.5.
Alchemy
Types
- AlterTableBuilder
- BCryptDigest
- BasicAuthMiddleware
- BcryptError
- BelongsToRelationship
- CORSMiddleware
- CORSMiddleware.AllowOriginSetting
- CORSMiddleware.Configuration
- ColumnType
- CreateColumn
- CreateColumnBuilder
- CreateIndex
- CreateTableBuilder
- DatabaseConfig
- DatabaseError
- DatabaseField
- DatabaseKeyMappingStrategy
- DatabaseValue
- DayUnit
- Env
- FrequencyTyped
- Grammar
- HTTPAuth
- HTTPAuth.Basic
- HTTPAuth.Bearer
- HTTPBody
- HTTPError
- HasManyRelationship
- HasOneRelationship
- HasRelationship
- HourUnit
- JoinClause
- JoinType
- Launch
- Log
- MIMEType
- MinuteUnit
- ModelQuery
- MySQLDatabase
- Operator
- OrderClause
- OrderClause.Sort
- OrderedDictionary
- PapyrusClientError
- PathParameter
- PathParameter.DecodingError
- PostgresDatabase
- Query
- Request
- Response
- Router
- RuneError
- SQL
- SQLJSON
- Scheduler
- Schema
- SecondUnit
- Services
- Socket
- StaticFileMiddleware
- StringLength
- Thread
- TokenAuthMiddleware
- WeekUnit
- Weekday
- WhereBoolean
- WhereColumn
- WhereIn
- WhereIn.InType
- WhereNested
- WhereRaw
- WhereValue