Observable Field
A utility extension to observe changes to a field. It can be used to simply general tasks used in everyday projects like changing UI when API request is successful, filtering list items etc.
Documentation
Update value of observable. Calls the
OnChange
event with old a new value.
Get value of observable. Returns null if no value is set.
The event which is called after the change of the property is made. The value of the property has already been changed when this event is invoked.
Usage
Lets create a simple project that loads an html file using Web
component and displays it using a label. We will show ProgressBar
while data loads and a Snackbar
with retry button in case of an error.
UI
Blocks
- Lets start by creating a procedure that shows progressbar and hides other visible components.
- Next create a procedure
getData
that gets the file from network.
- We have added two observables called
DataObservable
&ErrorObservable
. First one observes changes to data while the other observes changes to error. We can use theOnChange
blocks from these observables tocperform different operations whenever data or error changes. When data changes, we will show data to the user & when error changes, we will show snackbar to the user.
- Next we will use
Web.GotText
event to handle request result. If our request is successful, we will change the value ofDataObservable
other we will change value ofErrorObservable
.
- To handle timeout and other network error, we will add blocks given below.
- Finally to get data when screen starts or when user clicks on retry button, we will use following events.
Project Files
- APK File: Observable.apk (5.2 MB)
- AIA File: ObservableSampleSimple.aia (42.5 KB)
- Advance Usage Sample: ObservableSampleAdvance.aia (233.5 KB)
Download Extension
1.0.0
- AIX File : com.dreamers.observablefield.aix (38.3 KB)
OpenSource
Changelog
1.0.0
- Adds functionality to create a single observable field.