From 8c1de6165d0a738ed73c99f88911cdd0a9745d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Pin=CC=83era=20Buendi=CC=81a?= Date: Tue, 25 Oct 2016 21:21:45 +0200 Subject: [PATCH] [enh/feature-registration] Add extra method to the protocol HUBFeatureRegistry that supports passing a feature for registering --- include/HubFramework/HUBFeatureRegistry.h | 12 ++++++++++++ sources/HUBFeatureRegistryImplementation.m | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/HubFramework/HUBFeatureRegistry.h b/include/HubFramework/HUBFeatureRegistry.h index f2da0dcf..0bfbc92f 100644 --- a/include/HubFramework/HUBFeatureRegistry.h +++ b/include/HubFramework/HUBFeatureRegistry.h @@ -26,6 +26,7 @@ @protocol HUBActionHandler; @protocol HUBViewControllerScrollHandler; @class HUBViewURIPredicate; +@class HUBFeatureRegistration; NS_ASSUME_NONNULL_BEGIN @@ -71,6 +72,17 @@ NS_ASSUME_NONNULL_BEGIN actionHandler:(nullable id)actionHandler viewControllerScrollHandler:(nullable id)viewControllerScrollHandler; + +/** + * Register a feature with the Hub Framework + * + * @param feature to be registered. + * + * Registering a feature with the same identifier as one that is already registered is considered a severe error and will + * trigger an assert. + */ +- (void)registerFeature:(HUBFeatureRegistration *)feature; + /** * Unregister a feature from the Hub Framework * diff --git a/sources/HUBFeatureRegistryImplementation.m b/sources/HUBFeatureRegistryImplementation.m index 06e135ea..6d08fd3f 100644 --- a/sources/HUBFeatureRegistryImplementation.m +++ b/sources/HUBFeatureRegistryImplementation.m @@ -99,6 +99,18 @@ - (void)registerFeatureWithIdentifier:(NSString *)featureIdentifier [self.registrationIdentifierOrder addObject:registration.featureIdentifier]; } +- (void)registerFeature:(HUBFeatureRegistration *)feature +{ + [self registerFeatureWithIdentifier:feature.featureIdentifier + viewURIPredicate:feature.viewURIPredicate + title:feature.featureTitle + contentOperationFactories:feature.contentOperationFactories + contentReloadPolicy:feature.contentReloadPolicy + customJSONSchemaIdentifier:feature.customJSONSchemaIdentifier + actionHandler:feature.actionHandler + viewControllerScrollHandler:feature.viewControllerScrollHandler]; +} + - (void)unregisterFeatureWithIdentifier:(NSString *)featureIdentifier { HUBFeatureRegistration * const registration = self.registrationsByIdentifier[featureIdentifier];