dominictarr / scuttlebutt

peer-to-peer replicatable data structure
Other
1.32k stars 66 forks source link

There is no `sync` event on SB or Model? #53

Open jacobbubu opened 4 years ago

jacobbubu commented 4 years ago

in the chapter Persistence of readme.markdown, the example is following:

var m = new Model()

//stream TO disk.
m.on('sync', function () {
  m.createReadStream().pipe(fs.createWriteStream(file))
})

I've not found sync event neither in 'index.js' nor 'model.js'

dominictarr commented 4 years ago

sync is emitted in the core Scuttlebutt code, for example here: https://github.com/dominictarr/scuttlebutt/blob/7b7f89ab569329334daaa1ed4e9a3ecbed224a66/index.js#L163

dominictarr commented 4 years ago

I havn't touched or used this in 5 years, so I can't remember all the details of how this worked internally. I just searched for the word emit('sync' and found that.

jacobbubu commented 4 years ago

I havn't touched or used this in 5 years, so I can't remember all the details of how this worked internally. I just searched for the word emit('sync' and found that.

Actually, sync only exists on stream, not model.