Skip to first unread message

Gabriel Pavan

unread,
Mar 26, 2017, 4:53:19 PM3/26/17
to MIT App Inventor Forum
So guys, im having trouble in this app that im building, that stores some logs in firebase.
The tag is like this (generated form a clock block): year/month/day (yyyy/MM/dd)
And the trouble is that as logs come into the database as they are generated by the app, i need to create a list under this tag for the daily log...
But when i try using append block from firebase, it just doesnt work and gets me an error like: Previous value was empty...
So im kinda lost here, if anybody can help would be AWESOME thxx...
Gabriel Pavan.

Taifun

unread,
Mar 26, 2017, 4:56:14 PM3/26/17
to MIT App Inventor Forum
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Gabriel Pavan

unread,
Mar 26, 2017, 5:03:25 PM3/26/17
to mitappinv...@googlegroups.com

So, here are the blocks
Look, the first call to getvalue, is to check is the set tag has a list under it, if so, then it just appends the wanted value to it, else, it makes the tag a list...

Taifun

unread,
Mar 26, 2017, 6:59:35 PM3/26/17
to MIT App Inventor Forum
the FirebaseDB works asynchronously
it does not make sense to send an AppendValue method directly after the StoreValue method
unfortunately I'm not very familiar with the FirebaseDB component, someone else probably might suggest a solution to that problem

Taifun

SteveJG

unread,
Mar 26, 2017, 7:23:34 PM3/26/17
to MIT App Inventor Forum
You may need to use the DataChanged block to make sure the data is actually stored before appending.  Also, as mentioned by Taifun,  both the StoreValue and AppendValue in the same event handler does not make a lot of sense.  There needs to be some delay.  Might be possible using a second Clock.Timer event handler in your app...I do not know.


You probably have read the description of the event handlers, methods etc. here      http://ai2.appinventor.mit.edu/reference/components/experimental.html#FirebaseDB  ; if not reading might provide some clues.

Regards,
Steve

Abraham Getzler

unread,
Mar 26, 2017, 10:41:37 PM3/26/17
to MIT App Inventor Forum
I'm not convinced the Append model is useful in FireBase.

Consider switching to a more atomic tag structure where each insert stands alone.

See this doc for a discussion of how I did it trying to do
Rock Paper Scossors on FireBase.

ABG

Gabriel Pavan

unread,
Mar 27, 2017, 12:37:23 AM3/27/17
to MIT App Inventor Forum
Thxx guys for the support, special thxx to Abraham who took it a little deeper and understood the problem...
For the ones that said the stuff about the Store and append in the same block, the storevalue is an attempt for creating the list before trying to add to it, cuz when i didnt do that, the app throws out error: previous value was empty, and does not stores anything at all...
Anyways, thxx for it all...
srry for my crappy english, im brazilian...

SteveJG

unread,
Mar 27, 2017, 10:16:38 AM3/27/17
to MIT App Inventor Forum
@ ABG ...Abraham.. append  adds an item to a list that is in a tag. If you show the result following an append using the DataChanged block the method will report the tag and the new value correctly .  However this does not automatically adjust the database.  What I do is 

Use the GetValue block immediately after calling AppendValue and the database then knows the value is appended.  This seems to be a bug but the workaround 'fixes' it,
at least in my Firebase project.



-- Steve
Reply all
Reply to author
Forward
0 new messages