-
Notifications
You must be signed in to change notification settings - Fork 14
Cobalt Web Lifecycle Messages
Cobalt automatically sends messages to the webpages to notice te web developper about the application state changes.
There is 3 categories of messages which are explained below:
- Application state messages
- Page state messages
- Weblayer messages
All those messages are PubSub messages but are sent to the web side only.
Here is a workflow of all lifecycle messages.
There are 3 messages in this category :
cobalt:onAppStarted
cobalt:onAppBackground
cobalt:onAppForeground
All of them are sent to the top/latest Cobalt view created.
Occurs when application is started. It is not fired when app is sent to background and then foreground again.
Occurs when the user leaves the application without killing it, by switching to an other app or pressing the device home button.
- On iOS it is also fired when double-tapping on the main button (to switch app).
- On Android it is also fired when displaying currently running application list and switching to another app or removing the app from the list.
Occurs when the user comes back to the application when it was previously in background mode. It can be when the user taps the app icon on the home screen or the application list or switching to it from the currently running application list.
There is only 1 message in this category for now :
cobalt:onPageShown
Occurs when the page is displayed to the user. It can be :
- when the page is created
- when the user get back to it after he pops out from another view
- when switching app and coming back again
You can rely on it to create or update your view to latest changes.
When coming back from background mode, cobalt:onPageShown
is fired after cobalt:onAppForeground
.
cobalt:onPageShown
receives one parameter : data. This represent the data that was sent with cobalt.navigate.push, replace and modal if defined.
Weblayer are also sending messages to the parent page to track their lifecycle.
There is :
cobalt:onWebLayerDismissed
cobalt:onWebLayerLoading
cobalt:onWebLayerLoaded
cobalt:onWebLayerLoadFailed
All of them are explained on the Weblayer page.
Cobalt is an Open-Source Hybrid Mobile Framework. Read more about it on the home page or in the documentation
- Introduction to Cobalt navigation
- The cobalt.json file
- native navigation bars
- Handling the Android back button
- Introduction to Cobalt messages
- Publish/Subscribe on the Web side
- Publish/Subscribe on Android
- Publish/Subscribe on iOS
- Web Lifecycle messages
- Pull-To-Refresh and Infinite Scroll
- Custom alerts and Toasts
- LocalStorage
- OpenExternalUrl
- PlatformInfos
- Ajax
- Removing the top bar
- Adding Cobalt to an existing project
- Customizing your hybrid views
- Handle multiple Cobalt webviews on the same screen (TODO)