gpt4 book ai didi

javascript - 进一步/递归对象解构

转载 作者:太空宇宙 更新时间:2023-11-04 03:21:16 26 4
gpt4 key购买 nike

我有这个:

const {ops} = getOplogStreamInterpreter(strm);

ops.del.subscribe(v => {
console.log('delete happened 1.');
});

ops.insert.subscribe(v => {
console.log('insert happened 1.');
});

ops.update.subscribe(v => {
console.log('update happened 1.');
});

只是想知道是否可以做到这一点:

const {{insert,del,update}} = getOplogStreamInterpreter(strm);

基本上进一步解构返回的对象。

最佳答案

我认为你可以这样做:

const { ops: { del, insert, update } } = getOplogStreamInterpreter(strm);

del.subscribe(v => {
console.log('delete happened 1.');
});

insert.subscribe(v => {
console.log('insert happened 1.');
});

update.subscribe(v => {
console.log('update happened 1.');
});

关于javascript - 进一步/递归对象解构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49909622/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com