HUBComponentRegistry
@protocol HUBComponentRegistry <NSObject>
Protocol defining the public API of a Hub component registry
A component registry manages a series of registered HUBComponentFactory
implementations,
that are used to create components for Hub Framework-powered views. To integrate a component
with the framework - implement a HUBComponentFactory
and register it with the registry.
You don’t conform to this protocol yourself, instead the application’s HUBManager
comes
setup with a registry that you can use.
-
Register a component factory with the Hub Framework
The registered factory will be used to create components whenever a component model declared the given component namespace as part of its
componentIdentifier
.Declaration
Objective-C
- (void)registerComponentFactory: (nonnull id<HUBComponentFactory>)componentFactory forNamespace:(nonnull NSString *)componentNamespace;
Parameters
componentFactory
The factory to register
componentNamespace
The namespace to register the factory for
-
Unregister a component factory from the Hub Framework
After this method has been called, the Hub Framework will remove any factory found for the given namespace, opening it up to be registered again with another factory. If the given namespace does not exist, this method does nothing.
Declaration
Objective-C
- (void)unregisterComponentFactoryForNamespace: (nonnull NSString *)componentNamespace;
Parameters
componentNamespace
The namespace of the factory to unregister
-
Create a new component instance for a model
Normally, you don’t have to call this method yourself. Instead, the Hub Framework automatically creates component instances for the models you delcare in a content operation.
Declaration
Objective-C
- (nonnull id<HUBComponent>)createComponentForModel: (nonnull id<HUBComponentModel>)model;
Parameters
model
The model to create a component for
Return Value
A newly created component that is ready to use. The component registry will first attempt to resolve a component factory for the model’s
componentNamespace
, and ask it to create a component. However, if this fails, the registry will use its fallback handler to create a fallback component for the model’scomponentCategory
.