HUBFeatureRegistry

@protocol HUBFeatureRegistry <NSObject>

Protocol defining the public API of a Hub feature registry

A feature is the top-level entity in the Hub Framework, that is used to ecapsulate related views into a logical group. Views that belong to the same feature share the same setup, such as a view URI predicate, content operation factories, etc.

  • Register a feature with the Hub Framework

    Registering a feature with the same identifier as one that is already registered is considered a severe error and will trigger an assert.

    Declaration

    Objective-C

    - (void)
    registerFeatureWithIdentifier:(nonnull NSString *)featureIdentifier
                 viewURIPredicate:(nonnull HUBViewURIPredicate *)viewURIPredicate
                            title:(nonnull NSString *)title
        contentOperationFactories:
            (nonnull NSArray<id<HUBContentOperationFactory>> *)
                contentOperationFactories
              contentReloadPolicy:
                  (nullable id<HUBContentReloadPolicy>)contentReloadPolicy
       customJSONSchemaIdentifier:(nullable NSString *)customJSONSchemaIdentifier
                    actionHandler:(nullable id<HUBActionHandler>)actionHandler
      viewControllerScrollHandler:
          (nullable id<HUBViewControllerScrollHandler>)viewControllerScrollHandler;

    Parameters

    featureIdentifier

    The identifier of the feature. Used for logging & error messages. Must be unique across the app.

    viewURIPredicate

    The predicate that should be used to determine whether a given view URI is part of the feature. Use HUBViewURIPredicate to define a predicate that matches what type of view URIs your feature should handle.

    title

    The title of the feature. This will be sent as part of the feature info to the content operations for views created for the feature. Should be fully localized and ready to be presented in the user interface.

    contentOperationFactories

    The factories that should be used to create content operations for the feature’s views. The order of the factories will determine the order in which the created content operations are called each time a view that is a part of the feature will load content. See HUBContentOperationFactory for more information.

    contentReloadPolicy

    Any custom content reload policy that should be used for the feature. A content reload policy determines whenever a view belonging to the feature should have its content reloaded. If nil, the default reload policy for this instance of the Hub Framework will be used. See HUBContentReloadPolicy for more information.

    customJSONSchemaIdentifier

    Any identifier of a custom schema to use to parse JSON data. If nil, the default schema will be used. Register your custom schema using HUBJSONSchemaRegistry. See HUBJSONSchema for more info.

    actionHandler

    Any custom action handler that should be used for the feature. If nil, any default action handler for this instance of the Hub Framework will be used. Action handlers can be used to run custom code instead of performing actions. See HUBActionHandler for more info.

    viewControllerScrollHandler

    Any custom scroll handler to use to handle scroll events and customize scrolling behavior of view controllers created for this feature. See HUBViewControllerScrollHandler for more info.

  • Unregister a feature from the Hub Framework

    After this method has been called, The Hub Framework will remove all information stored for the given identifier, and open it up to be registered again for another feature. If the given identifier does not exist, this method does nothing.

    Declaration

    Objective-C

    - (void)unregisterFeatureWithIdentifier:(nonnull NSString *)featureIdentifier;

    Parameters

    featureIdentifier

    The identifier of the feature to unregister