Comments (7)
怎么样删除一个key啊?
from data.js.
@ymssn set('***', undefined);
from data.js.
谢谢。
再请教一下,我有个需求目前的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.
@ysmssn 你的需求接近于标准的Object.observe了
from data.js.
我的理解这种情况下,应该把订阅放到user上
data.sub('user', updatecb);
问题是 此时data.set('user.789', xxx)
,事件并不会向上发送到user,这是data的一个缺陷,此时你可以用下面的方法代替
data.set('user', {789: xxx});
set时会merge而不是覆盖,能够满足你的需求
from data.js.
还有建议,问问题不要来这个issue下,新建一个吧,这里主要是收集资料的
from data.js.
关于事件向上发送这个缺陷,我这边一直没有时间修复
from data.js.
Related Issues (8)
- Data.set参数为对象时的疑问 HOT 3
- Data.js在Nodejs端能做缓存模块不? HOT 1
- 是否考虑写一个跟immutable.js结合的版本? HOT 10
- 消息不会向上派发?
- get接口获取的深度clone数据,会获取到原型链上的数据
- 关于测试 HOT 3
- 能实现nodejs中多个线程共享数据吗? HOT 1
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 data.js.