-
Notifications
You must be signed in to change notification settings - Fork 8
Lifecycle
Cilantro is a single page application (SPA) which means that it is responsible for handling the browser history (back button) and rendering the appropriate data and views on the page for each URL.
Cilantro comes with a cilantro/main
module that does all the setup of the session, data, and routes, but when customization is required, application code can override or inject functionality into Cilantro. Below is an ordered listing of events that make the lifecycle of Cilantro.
Events are triggered by the cilantro
object.
The application has initialized and has begun loading external dependencies defined in the configuration. Additional dependencies and configuration tweaking can be done here. See #754
c.on('init', function(c) {
// Do additional setup
});
The application has loaded all external dependencies and is ready to open a session. Views that do not require any data can be initialized and rendered.
c.on('ready', function(c) {
c.sessions.open({ ... });
});
Events are triggered on the cilantro.sessions
object. See #755
The request to the service root has been sent and waiting for a response.
c.sessions.on('session:opening', function(session) {
// Display notification..
});
The client is not authorized to connect to the service. For services that require authentication, credentials can be supplied when opening the session.
c.sessions.open({
credentials: {
username: 'foo',
password: 'secr3t'
}
});
An unknown error occurred while opening the session. This is usually due to a service error.
c.sessions.on('session:error', function(session, error) {
// Display notification..
});
The session has been successfully opened, the data stores have been initialized, and referenced at session.data
. Views that require data can be initialized. For convenience, a reference to the active session is available at cilantro.session
.
c.sessions.on('session:opened', function(session) {
// Start rendering data-driven views..
});
The session has been closed. All data for the session has been dereferenced.
Once the session is opened and views have been initialized, the next step is to define the URL routes. This is a mapping between the URL and a set of views that should be rendered on the page when that URL is navigated to. The cilantro/main
module comes with a set of routes for the workspace, query, and results pages.
Once the routes have been declared, they are passed in the session.start()
method to trigger the route for the current URL.
Note: These data events are deprecated.
-
CONCEPT_FOCUS(id)
- The concept identified byid
has gained focus. -
CONTEXT_SYNCED(context, status)
- A context has synced.status
may be success or error. -
CONTEXT_INVALID(invalidFilters)
- A context is not valid due to one or more filters. -
VIEW_SYNCING(view)
- A view is syncing. -
VIEW_SYNCED(view, status)
- A view has synced.status
may be success or error. -
VIEW_CHANGED(view)
- A view changed.