HUBViewModel

@protocol HUBViewModel <HUBSerializable>

Protocol defining the public API of a model that is used for a View in the Hub Framework

You don’t conform to this protocol yourself, instead the Hub Framework will create implementations of it for you based on the data supplied to a HUBViewModelBuilder or through JSON data.

See also HUBViewController that acts as the controller for a view that renders the data from a HUBViewModel.

  • The identifier of the view

    The value of this property doesn’t have any specific format or constraints, and is up to the API user to define according to the context of the application. Doesn’t explicitly need to be unique, but for logging and identification purposes, it’s definitely recommended.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *identifier;
  • The navigation item that the view should use when presented in a UINavigationController

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) UINavigationItem *navigationItem;
  • The model for any component that make up the view’s header

    If the view should not use a component-based header, and instead just display a normal UINavigationBar, this property will be nil.

    See HUBComponentModel for more information on how component models work.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) id<HUBComponentModel>
        headerComponentModel;
  • The models for the components that make up the view’s body

    See HUBComponentModel for more information on how component models work.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic)
        NSArray<id<HUBComponentModel>> *_Nonnull bodyComponentModels;
  • The models for the components that will be rendered as overlays for the view

    See HUBComponentModel for more information on how component models work.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic)
        NSArray<id<HUBComponentModel>> *_Nonnull overlayComponentModels;
  • Any custom data that is associated with the view

    This dictionary contains any custom data passed from the server side, or added in the local content loading process.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable)
        NSDictionary<NSString *, id> *customData;
  • The date when this view model was built by the Hub Framework

    You can use this property to determine the age of the view model, to make decisions on whether to reload a view’s content or not. It will be set when the view model is built by a HUBViewModelBuilder according to the current date of the device.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) NSDate *_Nonnull buildDate;