HubCategory
public final class HubCategory : Category
extension HubCategory: HubCategoryBehavior
extension HubCategory: DefaultLogger
extension HubCategory: Resettable
Amplify has a local eventing system called Hub. It is a lightweight implementation of Publisher-Subscriber pattern, and is used to share data between modules and components in your app. Hub enables different categories to communicate with one another when specific events occur, such as authentication events like a user sign-in or notification of a file download.
-
Declaration
Swift
public let categoryType: CategoryType
-
Adds
pluginto the list of Plugins that implement functionality for this category.The default plugin that is assigned at initialization will function without an explicit call to
configure. However, adding a plugin removes the default plugin, and will also cause the Hub category to requireconfigurebe invoked before using any logging APIs.Note: It is a programmer error to use
Amplify.HubAPIs during the initialization and configuration phases of a custom Hub category plugin.Declaration
Swift
public func add(plugin: HubCategoryPlugin) throwsParameters
pluginThe Plugin to add
-
Returns the added plugin with the specified
keyproperty.Declaration
Swift
public func getPlugin(for key: PluginKey) throws -> HubCategoryPluginParameters
keyThe PluginKey (String) of the plugin to retrieve
Return Value
The wrapped plugin
-
Removes the plugin registered for
keyfrom the list of Plugins that implement functionality for this category. If no plugin has been added forkey, no action is taken, making this method safe to call multiple times.Declaration
Swift
public func removePlugin(for key: PluginKey)Parameters
keyThe key used to
addthe plugin -
Declaration
Swift
public func dispatch(to channel: HubChannel, payload: HubPayload) -
Declaration
Swift
public func listen( to channel: HubChannel, eventName: HubPayloadEventName, listener: @escaping HubListener ) -> UnsubscribeToken -
Declaration
Swift
public func listen( to channel: HubChannel, isIncluded filter: HubFilter? = nil, listener: @escaping HubListener ) -> UnsubscribeToken -
Declaration
Swift
public func removeListener(_ token: UnsubscribeToken) -
Declaration
Swift
public static var log: Logger { get } -
Declaration
Swift
public var log: Logger { get } -
reset()AsynchronousDeclaration
Swift
public func reset() async -
Convenience method to allow callers to listen to Hub events for a particular operation. Internally, the listener transforms the HubPayload into the Operation’s expected OperationResult type, so callers may re-use their
listenersDeclaration
Swift
func listenForResult<Request: AmplifyOperationRequest, Success, Failure: AmplifyError>( to operation: AmplifyOperation<Request, Success, Failure>, resultListener: @escaping AmplifyOperation<Request, Success, Failure>.ResultListener ) -> UnsubscribeTokenParameters
operationThe operation to monitor for results
resultListenerThe Operation-specific listener callback to be invoked when an OperationResult for that operation is received.
-
Convenience method to allow callers to listen to Hub in-process events for a particular operation. Internally, the listener transforms the HubPayload into the Operation’s expected InProcess type, so callers may re-use their
listeners.Declaration
Swift
func listenForInProcess<Request: AmplifyOperationRequest, InProcess, Success, Failure: AmplifyError>( to operation: AmplifyInProcessReportingOperation<Request, InProcess, Success, Failure>, inProcessListener: @escaping AmplifyInProcessReportingOperation< Request, InProcess, Success, Failure >.InProcessListener ) -> UnsubscribeTokenParameters
operationThe progress reporting operation monitor for progress and results
inProcessListenerThe ProgressListener callback to be invoked when the operation emits an in-process value
View on GitHub