2019年4月22日月曜日

A simple demo app using ThunkableX Cloud Variables

Of the few existing App Inventors, ThunkableX has its own distinctive features. Except for being able to create common source programs (blocks) for Android and iOS, I focused on the newly introduced cloud variables. These extend the scope of traditional variables to cloud space based on the Firebase (a kind of real-time database). Normally, the database is created with a user-specific id, but if you know its URL, you can access that cloud variable. When an authorized user updates the value of a variable, the event is immediately received by other apps. Such a facility enables efficient development of database applications, etc.

An example of initializing such cloud variables is shown in Figure 1. You can see that Firebase tags can be mapped to cloud variables. Hierarchical tags can also be cloud variables, such as “fireLoc/lat”.


After initializing these cloud variables, they can be referenced in several ways. Figure 2 shows five access blocks for the cloud variable Betty. Particularly, I would like to note a block called “when Cloud Betty is initialized or changed”. This block allows you to know in real-time the updates to cloud variables, and based on that you can easily set up your application logic.


Gram app [2] is a famous example of using cloud variables. This is a very fine app, but it's somewhat complicated for general programmers. So I created a simpler demo app. Figure 3 shows that. Jack wants to know the location of his daughter Betty in real-time. But, Betty allows sending her location only when she presses a button on her smartphone.


The complete block diagram of ThunkableX that achieves this is shown in Figure 4. Figure 4(a) is for the sender, Betty; and Figure 4(b) is for the receiver, Jack. This diagram shows that using cloud variables make programming much easier. You can access the contents of the database without using Firebase blocks such as registering listeners, storing values in the database, etc. In Fig. 4(a), the location information is fetched by GetCurrentLocation and stored in the cloud variable Betty. Also, in Figure 4(b), updates to the cloud variable Betty is automatically detected, so the result is immediately reflected in the map.


References
[1] thunkable cloud variables, https://docs.thunkable.com/variables
[2] the Gram app, https://x.thunkable.com/projectPage/5bbff7e035aa10fd7702f479

1 件のコメント: