FirebaseDB GetValue gets data if there is no connection

234 views
Skip to first unread message
Assigned to j...@mit.edu by taifu...@gmail.com

I|I

unread,
May 8, 2016, 5:33:14 AM5/8/16
to MIT App Inventor Forum

I created a timer which checks the connection every 3 seconds. It sets the text of a label to "No connection" and immediently replaces it with "connected to computer" or "computer not connected" if there is a connection. I thought if there is no connection, the text of the label would not be replaced so it would show "No connection" but it is replaced with "computer not connected" although it can not get any value from firebase. So what do I fail to see? Does the firebaseDB not work like I think it does?


My Blockcode:

Blocks.JPG

Taifun

unread,
May 11, 2016, 5:55:20 PM5/11/16
to MIT App Inventor Forum
I can confirm this issue, I used the following blocks

after building the example, running a little bit and then setting the device to airplane mode I still get "connection=something" each time the clock.timer event fires
@Jeff: why is that?
Taifun
PS: example project attached
firebase.aia

jis

unread,
May 12, 2016, 8:43:12 AM5/12/16
to MIT App Inventor Forum
Firebase works “off-line.” If you are not connected to the network, Firebase caches results and behaves as if it is connected. If while your application is running you *do* get a network connection, then the values you store will be uploaded to Firebase.

If you exit your application any values you store will be lost (I believe).

There is a “persist” flag, which we haven’t yet made available in App Inventor, that will instruct Firebase to save off-line values and upload them the next time you run your application with a network connection. We are planning on adding this functionality in the future (I’m debating if I want to squeeze it into this upcoming component release). The persist flag will make Firebase a great solution for programs that need to do off-line data capture for later upload. We have some demand for that functionality.

-Jeff

Reply all
Reply to author
Forward
0 new messages