H5Service
, H5Session
and H5Page
are all extended from H5CoreNode
class. With H5Service
as the root node, they together forms a tree structure to represent the page flow and navigation. In normal circumstance, H5Pages
are the leaf nodes to H5Session
, whereas H5Sessions
are the leaf nodes to H5Service
, there is only one H5Service
in any case.
H5Service
is the base class for maintaining global state of H5 application. There is only one singleton global instance of H5Service
in the life cycle of H5 application, followings are some operations that you can use H5Service
to perform
A H5Session
is a stack of H5Pages
that forms a complete business flow. e.g., A process of checkout could involves a few pages: A summary page to review the shopping cart, a payment method selection page to choose the desired payment method, and finally a payment page to fill in the payment info and confirm. All these pages can behave independently, and the role of H5Session
here is to put these pages together, manage the sequence, handle the dependencies and achieve the business goal.
When you use H5Service
to create and start a new web page, a new H5Session
will be instantiated if there is none, and the subsequently created new pages will be added to this H5Session
. You can also remove pages from the H5Session
until the page stack is empty. H5Session
also provides convenient methods for you to retrieve the top page or register a listener to listen to the life cycle events of H5Session
.
H5Page
is the tangible component that user can actually see and interact with, and it is one of the most important part of an application’s overall life cycle. You can load the content by specifying a URL, customize the appearance and behavior of H5Page
through a list of H5Param
, and since you have the full access of its view hierarchy, it is also possible to put the H5Page
together with other native UI components in the same layout.
Nebula provides a event mechanism the allow event to be propagated among H5Page
, H5Session
and H5Service
. A H5Event
can occurs in H5Page
, H5Session
or H5Service
, and there are two process in the event dispatch.
H5Service
-> H5Session
or H5Page
, event can be intercepted ( if interceptEvent()
returns true ) at any node during this propagationH5Page
-> H5Session
or H5Service
, event can be handled ( if handleEvent()
returns true ) at any node during this propagationIf the event is intercepted or handled during interception or handling, the event is considered consumed and will not be propagated further, if a event is not consumed in both interception or handling after the dispatch, a error signal will be emitted to the caller.