Correct set() behaviour (return new ref)
This commit is contained in:
parent
bd4b0f9736
commit
642d7592ac
1 changed files with 6 additions and 4 deletions
|
|
@ -78,6 +78,7 @@ const handleMsg = msg => {
|
||||||
|
|
||||||
if (pendingPut) {
|
if (pendingPut) {
|
||||||
pendingPutsForPath.splice(idx, 1)
|
pendingPutsForPath.splice(idx, 1)
|
||||||
|
|
||||||
if (pendingPut.cb) {
|
if (pendingPut.cb) {
|
||||||
pendingPut.cb(ack)
|
pendingPut.cb(ack)
|
||||||
}
|
}
|
||||||
|
|
@ -170,7 +171,7 @@ const forge = () => {
|
||||||
currentGun = newGun
|
currentGun = newGun
|
||||||
|
|
||||||
// currentGun.on('', e => {
|
// currentGun.on('', e => {
|
||||||
// console.log('event from subp')
|
// console.log('event from subprocess')
|
||||||
// console.log(e)
|
// console.log(e)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
@ -351,16 +352,17 @@ function createReplica(path, afterMap = false) {
|
||||||
throw new Error('Cannot call set() after map() on a GunSmith node')
|
throw new Error('Cannot call set() after map() on a GunSmith node')
|
||||||
}
|
}
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const uuid = Gun.text.random()
|
const id = Gun.text.random()
|
||||||
return this.put(
|
this.put(
|
||||||
{
|
{
|
||||||
[uuid]: data
|
[id]: data
|
||||||
},
|
},
|
||||||
ack => {
|
ack => {
|
||||||
// eslint-disable-next-line no-unused-expressions
|
// eslint-disable-next-line no-unused-expressions
|
||||||
cb && cb(ack)
|
cb && cb(ack)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return this.get(id)
|
||||||
},
|
},
|
||||||
user(pub) {
|
user(pub) {
|
||||||
if (path !== '$root') {
|
if (path !== '$root') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue