I've got Gun synchronizing across a couple of clients. On one I'm subscribing to the data using map().on(). On the other I delete an item using map().unset(). My question, when I delete an item the changes pops up on the other client as null - I don't seem to have any other information. Is it possible then to keep my client in-sync with changes i.e. in this case remove the item from the list I am showing on the screen? I don't know which item null is referencing to.
Thanks!
@peter great question! Two things:
As a background on what the null
is doing for deleting, you probably already saw https://gun.eco/docs/Delete .
To answer your question, .on
callback has multiple parameters, so .on(function(data, key
is what you want. Data will be null
and you know which item it was based on the key
. Check out the rest of the API here!
Pro tip: If
gun.get('list').map().on((data, key) => ...)
grabs all the items thengun.get('list').get(key).on(data => ...)
is how to grab only that one item from the table!