gun icon indicating copy to clipboard operation
gun copied to clipboard

Initial map().on() not triggering when put called with object

Open georgigriffiths opened this issue 4 years ago • 4 comments

Test available here https://github.com/georgigriffiths/gun/tree/master/test/map

georgigriffiths avatar Mar 31 '20 13:03 georgigriffiths

Updated tests and multiple chained get calls are not triggering the map().on(). The data is arriving at the remote node.

georgigriffiths avatar Mar 31 '20 15:03 georgigriffiths

So the bug is due to the empty first node.

BAD: gun.get('room/test').get('users').map().on()

GOOD: gun.get('room/test').put({id:'test'}).get('users').map().on()

georgigriffiths avatar Apr 02 '20 09:04 georgigriffiths

Any update on this? I'm hitting this right now with something similar to this:

gun.get("doc").map().on((data, key) => {
...
});
gun.get("doc").put({firstName: "John", lastName: "Doe"});

The on callback triggers properly when first ran, but any data added after that is not propagated.

gcoakes avatar Sep 20 '21 03:09 gcoakes

I think I'm getting the same, if not very similar issue after pulling and running the code from this tutorial https://www.youtube.com/watch?v=J5x3OMXjgMc.

Essentially, if I use a new unique id for the data I'm finding the first entry (or message posted) never shows up, only the following (second, third, etc) messages. Sending a blank first message prior to gun.get("some/room").map().on() as similar to what is shown by @georgigriffiths above is a workaround.

newtriks avatar Sep 28 '21 14:09 newtriks