Comments (4)
Ah, I got s.th.:
- since Gun merges new values with existing ones, setting
{}
simply merges nothing - i.e., it leaves the existing object unchanged and, thus, does not invoke the event handler - what still surprises me, however, is the observation that the code
const sharedData = Gun.get('sharingTest').get('sharedData')
sharedData.put({})
sharedData.on((Data) => { console.log('sharedData: "' + JSON.stringified(Data) + '"') })
sometimes writes onto the console, sometimes it doesn't (that's why I currently use this approach in my experiments in order to avoid the event handler being called initially, i.e., after loading previous contents from localStorage - which works most of the time...) are these "race conditions"?
Sorry for bothering you!
from gun.
I'm completely lost...
what I did:
const sharedData = Gun.get('sharingTest').get('sharedData')
sharedData.put({ a:'a' })
- works- waiting for completion using a "once" event handler - works
sharedData.put(null)
- works- waiting for completion using a "once" event handler - works
sharedData.put({ b:'b' })
- works- waiting for completion using a "once" event handler - oops
the last step shows that the previous contents (namely { a:'a' }
) reappear again - although I previously successfully overwrote the node with a primitive!
How can that be? I am not yet using any relay - everything works locally only (albeit with "localStorage" in the background, if I understood the concepts correctly)
from gun.
{}
is an empty set, so if it is merging into an existing object then no actual change occurs, however I do believe the lower level events get fired, but .on(
etc. dedups it.
if you overwrite something with a primitive, then re-save an object to it... it'll re-generate the same deterministic soul on that path, thus it'll "re-find" the old data.
var newNode = gun.get("randomID").put({b: 'b'}); sharedData.put(newNode);
will force a different node onto it, overwriting the previous and NOT re-merging with a previous node. But note: This can lead to disparity in offline apps if this happens a lot, as offline apps might not generate the same "location" to converge too.
from gun.
Thank you very much for your explanation.
However, I somewhere found the "recipe" to first nullify an object and then to write a new one using the same context (I have to find where, but I'm really lost in the jungle of overlapping doc sections and wiki pages...). This recipe would contradict your explanation then.
from gun.
Related Issues (20)
- fakeS3 option not being recognised HOT 1
- [Bug?] wrong key path in error message HOT 1
- [Docs] where is "Gun.chain" documented? HOT 2
- [Docs] are really difficult to use! HOT 4
- are there any recipies how to model data structures properly for Gun? HOT 1
- [Doc] user example is wrong? HOT 2
- [Doc] how can one find the root node of a given user? HOT 2
- [Doc] how can one write encrypted data? HOT 2
- [Doc] is the SEA Quickstart example wrong? HOT 3
- [RAD] I'm completely lost... HOT 9
- If you put data in a key with one gun instance, then change that data on another gun instance, the first instance will be unable to read the change HOT 5
- Unable to use Array.push inside once() HOT 1
- Loading sea.js with importScripts fails in worker HOT 6
- [Bug] _ev.off() disables the entire .map() listener, rather than the individual item HOT 1
- Silent Failure on Incorrect Certificate and Delayed put HOT 1
- How to deploy gun server by Docker? HOT 4
- [Question] Netx.js support? HOT 1
- Why is the source code so bad? HOT 2
- Can not access docs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gun.