HUBViewModelLoader

@protocol HUBViewModelLoader <NSObject>

Protocol defining the public API of a view model loader

You don’t conform to this protocol yourself, instead the Hub Framework will create objects conforming to this protocol internally. This API is currently not accessible from outside of the Hub Framework, but will be soon as part of the external data API.

  • The view model loader’s delegate

    Assign a custom object to this property to get notified of events. See HUBViewModelLoaderDelegate for more information.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<HUBViewModelLoaderDelegate>
        delegate;
  • The view model that should initially be used, before a proper view model has been loaded

    Accessing this property will either return a pre-computed initial view model, or cause the loader’s content operations to be asked to prepare an initial view model. The initial view model will then be cached, so it’s fine to access this property multiple times.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic)
        id<HUBViewModel> _Nonnull initialViewModel;
  • Whether the view model loader is currently loading

    True whenever one or more content operations are currently in the process of loading content, either as part of the main content loading chain, or as part of appending paginated content.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) BOOL isLoading;
  • Load a view model using this loader

    Depending on the current connectivity state (determined by the current HUBConnectivityStateResolver), and the configuration of the feature that his view model is serving, a combination of remote and local content will be loaded using the respective content operations.

    The loader will notify its delegate once the operation was completed or if it failed. See HUBViewModelLoaderDelegate for more information.

    Declaration

    Objective-C

    - (void)loadViewModel;
  • Load the next set of paginated content for the current view model this loader is for

    Use this method to extend the current view model with additional paginated content. The view model loader automatically manages the current state of the view and the page index for you, so all you have to do is to call this method whenever additional content should be loaded.

    Content loaded this way will be appended to the current view model, so if it already contains 2 component models (A & B), and a new one © is added through this mechanism - the resulting view model will now contain A, B & C.

    Calling this method invokes content operations conforming to HUBContentOperationWithPaginatedContent.

    The same delegate methods are called for success/error when the view model loader finishes this task.

    Calling this method before first loading a view model using loadViewModel does nothing.

    Declaration

    Objective-C

    - (void)loadNextPageForCurrentViewModel;