Using data slots for firebase path and condition sometimes yields empty table


#1

I’m using a couple of data slots

ds_topic_items = ‘/items/foree/contents’
ds_topic_name = ‘doc1’

used to configure firebase table like this…

collection id = $slot(‘ds_topic_items’)
where(“name”,"==","$slot(‘ds_topic_name’)")

so when the user clicks a navigation item it triggers a script…

this.props.appActions.updateDataSlot(‘ds_topic_name’, ‘new-name’ );
this.props.appActions.updateDataSlot(‘ds_topic_items’, ‘/some/new/path’ );

RS triggers two calls to loadData_firebase1(), once for each slot update
which is not a problem since the data is locally cached

sometimes, the table is not populated as it should be.

sometimes “things” get out of sync
in this example,
the name has changed first (red) and table length === 0 is expected.
then the path is updated (green) and table length should be > 0, but is not
image

so temporary fix is to hack

this.props.appActions.updateDataSlot()

such that the firebase query (this.loadData_firebase1)
…only runs once, after the name is updated,
…by ensuring that in my script, the name variable used in the where condition is updated AFTER the path variable.

is there any way to update both of these slots in one go?
is there a way I can persist the hack to App.js across “open in browser/export to react” events?


#2

Hmm. this is a b it tricky. What if you update the Data slot values directly to Data slot array?

I mean something like:

this.props.appActions.dataSlots(“dataslotname”) = “new value”

and use the this.props.appActions.updateDataSlot() for the last Data slot you need to update which then triggers the refresh?