Giter Club home page Giter Club logo

Comments (7)

ymssn avatar ymssn commented on June 12, 2024

怎么样删除一个key啊?

from data.js.

yanhaijing avatar yanhaijing commented on June 12, 2024

@ymssn set('***', undefined);

from data.js.

ymssn avatar ymssn commented on June 12, 2024

谢谢。
再请教一下,我有个需求目前的data.js无法实现:
比如有个用户对象数组:
user: {
'123': user1,
'456': user2
}
然后data.set('user', user);
其它组件就可以订阅user.123和user.456的事件了。
但是如果有新的用户data.set('user.789', user3);
其它组件就无法通过data.js的事件得到通知。
可否考虑添加一个事件newProperty
data.sub('newProperty', 'user', function(){});
当user这个key有新属性的时候触发?

from data.js.

latel avatar latel commented on June 12, 2024

@ysmssn 你的需求接近于标准的Object.observe了

from data.js.

yanhaijing avatar yanhaijing commented on June 12, 2024

我的理解这种情况下,应该把订阅放到user上

data.sub('user', updatecb);

问题是 此时data.set('user.789', xxx),事件并不会向上发送到user,这是data的一个缺陷,此时你可以用下面的方法代替

data.set('user', {789: xxx});

set时会merge而不是覆盖,能够满足你的需求

from data.js.

yanhaijing avatar yanhaijing commented on June 12, 2024

还有建议,问问题不要来这个issue下,新建一个吧,这里主要是收集资料的

from data.js.

yanhaijing avatar yanhaijing commented on June 12, 2024

关于事件向上发送这个缺陷,我这边一直没有时间修复

from data.js.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.