Controller
open class Controller
The base controller class.
-
Gets the contrainer’s communicationManager.
Declaration
Swift
private(set) public var communicationManager: CommunicationManager! { get } -
Gets the container object of this controller.
Declaration
Swift
private(set) public var container: Container! { get } -
Gets the container’s Runtime object.
Declaration
Swift
private(set) public var runtime: Runtime! { get } -
Gets the controller’s options as specified in the configuration options.
Declaration
Swift
private(set) public var options: ControllerOptions? { get } -
Gets the registered name of this controller.
The registered name is either defined by the corresponding key in the
Components.controllersobject in the container configuration, or by invokingContainer.registerControllermethod with this name.Declaration
Swift
private(set) public var registeredName: String { get } -
This dispose bag holds references to your observable subscriptions added with
.disposed(by: self.disposeBag). These subscriptions are automatically disposed when the communication manager is stopped (in theonCommunicationManagerStoppingbase method).Declaration
Swift
public var disposeBag: DisposeBag -
Never instantiate controller objects in your application; they are created automatically by dependency injection.
Remark
for internal use in CoatySwift framework only.Declaration
Swift
required public init(container: Container, options: ControllerOptions?, controllerType: String)
-
Advertise a Log object for debugging purposes.
Declaration
Swift
public func logDebug(message: String, tags: [String]...)Parameters
messagea debug message
tagsany number of log tags
-
Advertise an informational Log object.
Declaration
Swift
public func logInfo(message: String, tags: [String]...)Parameters
messagean informational message
tagsany number of log tags
-
Advertise a Log object for a warning.
Declaration
Swift
public func logWarning(message: String, tags: [String]...)Parameters
messagea warning message
tagsany number of log tags
-
Advertise a Log object for an error.
Declaration
Swift
public func logError(error: Any, message: String, tags: [String]...)Parameters
errora error (object)
messageadditional error message
tagsany number of log tags
-
Advertise a Log object for a fatal error.
Declaration
Swift
public func logFatal(error: Any, message: String, tags: [String]...)Parameters
erroran error (object)
messageadditional error message
tagsany number of log tags
-
Called when the container has completely set up and injected all dependency components, including all its controllers.
Use this method to perform initializations in your custom controller class instead of defining a constructor. Although the base implementation does nothing it is good practice to call super.onInit() in your override method; especially if your custom controller class extends from another custom controller class and not from the base
Controllerclass directly.Declaration
Swift
open func onInit() -
Called when the communication manager is about to start or restart. Implement side effects here. Ensure that super.onCommunicationManagerStarting is called in your override. The base implementation does nothing.
Declaration
Swift
open func onCommunicationManagerStarting() -
Called when the communication manager is about to stop. Implement side effects here. Ensure that super.onCommunicationManagerStopping is called in your override.
The base implementation disposes all observable subscriptions collected by the controller’s dispose bag (see
self.disposeBag) and reinitializes a new dispose bag afterwards.Declaration
Swift
open func onCommunicationManagerStopping() -
Called by the Coaty container when this instance should be disposed. Implement cleanup side effects here. The base implementation does nothing.
Declaration
Swift
open func onDispose()
-
Whenever one of the controller’s log methods (e.g.
logDebug,logInfo,logWarning,logError,logFatal) is called by application code, the controller creates a Log object with appropriate property values and passes it to this method before advertising it.You can override this method to additionally set certain properties (such as
LogHost.hostnameorLog.logLabels). Ensure thatsuper.extendLogObjectis called in your override. The base method does nothing.Declaration
Swift
open func extendLogObject(log: Log)Parameters
loglog object to be extended before being advertised
View on GitHub
Controller Class Reference