Observables are primitive types (boolean, byte, double, float, integer, long, short), strings, objects or collections (map, list, record) that trigger events when they are modified. They can also automatically update the views with which they are bound.
Example 1: You have associated an ObservableString with all the OK buttons of your application. By changing the value of this Observable (e.g. ofConfirmButton.Value = "OK"), you change at the same time the label of all OK buttons, regardless of the activity in which they are declared.
Example 2: In your application, you want to perform a task each time a list is modified by your code (e.g. saving the content to a file), regardless of the activity or sub in which that list is modified. By using an ObservableList, it becomes easy to perform the task according to the triggered event (Added, Cleared, Removed, Sorted, Updated).
Example 3: You have linked an ObservableField to a field in a database table. By changing the ID of this Observable, you get the value of the field corresponding to this ID and you trigger an Updated event. By changing the Observable value, you update the field in the database and trigger an Updated event.
Please note that this library is not based on the Observable class of Java. Its code is entirely written from scratch.
It exists a version for B4J here.
Example 1: You have associated an ObservableString with all the OK buttons of your application. By changing the value of this Observable (e.g. ofConfirmButton.Value = "OK"), you change at the same time the label of all OK buttons, regardless of the activity in which they are declared.
Example 2: In your application, you want to perform a task each time a list is modified by your code (e.g. saving the content to a file), regardless of the activity or sub in which that list is modified. By using an ObservableList, it becomes easy to perform the task according to the triggered event (Added, Cleared, Removed, Sorted, Updated).
Example 3: You have linked an ObservableField to a field in a database table. By changing the ID of this Observable, you get the value of the field corresponding to this ID and you trigger an Updated event. By changing the Observable value, you update the field in the database and trigger an Updated event.
Please note that this library is not based on the Observable class of Java. Its code is entirely written from scratch.
It exists a version for B4J here.
Attachments
Last edited: