app :: AppComponent
Most users of app.nit need only to implement on_create
to setup the application.
On mobile devices, the application can be stopped a anytime when another application takes the foreground.
Implement the callbacks on_save_state
and on_load_state
to keep the state of the application between execution,
for an illusion of continuous execution.
app :: AppComponent :: defaultinit
app :: AppComponent :: notify_observers
Propagateevent
to all observers
by calling AppObserver::on_event
app :: AppComponent :: observers
AllAppObserver
notified of events raised by self
app :: AppComponent :: observers=
AllAppObserver
notified of events raised by self
app :: AppComponent :: on_pause
The application leaves the active state but is still partially visibleapp :: AppComponent :: on_restart
The application returns to a visible state from a previouson_stop
app :: AppComponent :: on_restore_state
The application is launching, restore its state from a previouson_save_state
app :: AppComponent :: on_resume
The application enters the active state, it is in the foreground and interactiveapp :: AppComponent :: on_save_state
The application may be destroyed soon, save its state for a futureon_restore_state
app :: AppComponent :: on_start
The application is starting or restarting, it is visible to the userapp $ AppComponent :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
app :: AppObserver :: defaultinit
app :: AppComponent :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
app :: AppComponent :: notify_observers
Propagateevent
to all observers
by calling AppObserver::on_event
app :: AppComponent :: observers
AllAppObserver
notified of events raised by self
app :: AppComponent :: observers=
AllAppObserver
notified of events raised by self
app :: AppComponent :: on_pause
The application leaves the active state but is still partially visibleapp :: AppComponent :: on_restart
The application returns to a visible state from a previouson_stop
app :: AppComponent :: on_restore_state
The application is launching, restore its state from a previouson_save_state
app :: AppComponent :: on_resume
The application enters the active state, it is in the foreground and interactiveapp :: AppComponent :: on_save_state
The application may be destroyed soon, save its state for a futureon_restore_state
app :: AppComponent :: on_start
The application is starting or restarting, it is visible to the usercore :: Object :: output_class_name
Display class name on stdout (debug only).app :: HttpRequestClientWindow
Simple window with a label and a button
# An element of an application that is notified of the application life cycle
#
# Most users of _app.nit_ need only to implement `on_create` to setup the application.
#
# On mobile devices, the application can be stopped a anytime when another application takes the foreground.
# Implement the callbacks `on_save_state` and `on_load_state` to keep the state of the application between execution,
# for an illusion of continuous execution.
abstract class AppComponent
# The application is being created
#
# You should build the UI at this time.
#
# Triggers are platform specific:
# * Android: `Activity.onCreate`
# * iOS: `UIApplicationDelegate application:didFinishLaunchingWithOptions`
fun on_create do end
# The application enters the active state, it is in the foreground and interactive
#
# Triggers are platform specific:
# * Android: `Activity.onResume`
# * iOS: `UIApplicationDelegate applicationDidBecomeActive`
fun on_resume do end
# The application leaves the active state but is still partially visible
#
# It may then go back to `on_resume` or `on_stop`.
#
# Triggers are platform specific:
# * Android: `Activity.onPause`
# * iOS: `UIApplicationDelegate applicationWillResignActive`
fun on_pause do end
# The application is completely hidden from the user
#
# It may then be destroyed or go back to a paused state with `on_restart`.
#
# Triggers are platform specific:
# * Android: `Activity.onStop`
# * iOS: `UIApplicationDelegate applicationDidEnterBackground`
fun on_stop do end
# The application returns to a visible state from a previous `on_stop`
#
# Triggers are platform specific:
# * Android: `Activity.onRestart`
# * iOS: `UIApplicationDelegate applicationWillEnterForeground`
fun on_restart do end
# The application may be destroyed soon, save its state for a future `on_restore_state`
#
# Triggers are platform specific:
# * Android: `Activity.onSaveInstanceState`
# * iOS: `UIApplicationDelegate applicationDidEnterBackground`
fun on_save_state do end
# The application is launching, restore its state from a previous `on_save_state`
#
# Triggers are platform specific:
# * Android: `Activity.onCreate`, _not_ `Activity.onRestoreInstanceState`
# as it is trigged only if there is a previous Android specific save state.
# * iOS: `UIApplicationDelegate applicationDidEnterBackground`
fun on_restore_state do end
end
lib/app/app_base.nit:42,1--106,3
redef class AppComponent
super AppObserver
# All `AppObserver` notified of events raised by `self`
#
# By default, only `self` is an observer.
# Any other `AppObserver` can be added to this collection.
var observers = new HashSet[AppObserver].from([self: AppObserver])
# Propagate `event` to all `observers` by calling `AppObserver::on_event`
fun notify_observers(event: AppEvent)
do
for observer in observers do
observer.on_event(event)
end
end
end
lib/app/ui.nit:109,1--125,3
redef class AppComponent
# The application is starting or restarting, it is visible to the user
fun on_start do end
# The application is being destroyed
fun on_destroy do end
end
lib/android/nit_activity.nit:211,1--217,3