HUBContentOperation
@protocol HUBContentOperation <NSObject>
Protocol used to define objects that load content that will make up a Hub Framework view model
To define a content operation, conform to this protocol in a custom object - and return it from a matching
HUBContentOperationFactory that is passed when configuring your feature with the Hub Framework. A content
operation is free to do its work in whatever way it desires, online or offline - manipulating a view’s content
either in code or through JSON (or another data format) - synchronously or asynchronously.
When a new view is about to be displayed by the Hub Framework, the framework will call the content operations
associated with that view. The content that these content operations add to the used HUBViewModelBuilder will
then be used to create a view model for the view.
If your content operation also has some initial content that can be synchronously added to the view, before the
main content loading chain is started - it can conform to HUBContentOperationWithInitialContent to be able to
do so.
-
The content operation’s delegate. Don’t assign this property yourself, it will be set by the Hub Framework.
Declaration
Objective-C
@property (readwrite, nonatomic, nullable) id<HUBContentOperationDelegate> delegate; -
Perform the operation for a view with a certain view URI
The operation should perform any work to add, change or remove content to/from the view, and then call its delegate once done (either using the success or failure method). If the operation cannot perform any work at this point, it still needs to call the delegate to make the content loading chain progress.
Declaration
Objective-C
- (void)performForViewURI:(nonnull NSURL *)viewURI featureInfo:(nonnull id<HUBFeatureInfo>)featureInfo connectivityState:(HUBConnectivityState)connectivityState viewModelBuilder:(nonnull id<HUBViewModelBuilder>)viewModelBuilder previousError:(nullable NSError *)previousError;Parameters
viewURIThe URI of the view that the content operation is being used in
featureInfoAn object containing information about the feature that the operation is being used in
connectivityStateThe current connectivity state, as resolved by
HUBConnectivityStateResolverviewModelBuilderThe builder that can be used to add, change or remove content to/from the view
previousErrorAny error encountered by a previous content operation in the view’s content loading chain. If this is non-
nil, you can attempt to recover the error in this content operation, to provide any relevant content to avoid displaying an error screen for the user. In case this content operation can’t recover the error, it should propagate the error using the error delegate callback method.
View on GitHub
Install in Dash
HUBContentOperation Protocol Reference