inshua / d2js Goto Github PK
View Code? Open in Web Editor NEWd2js - 前后端web数据框架; jssp - Javascript Server Page;
License: MIT License
d2js - 前后端web数据框架; jssp - Javascript Server Page;
License: MIT License
淘宝“宝贝详情页”上,有个跟卖家聊天的按钮,点击之后可以跟卖家直接聊天。
现在考虑这样一个场景,如果点击聊天之后,卖家下面的“联系我”变成“正在联系”,然后弹出聊天窗口,关闭聊天窗口后恢复成“联系我”。
从redux方面来看,它像个巨大的观察者,不管是界面变化还是用户变化,它都会进行观察,如果需要对应的数据,只要订阅到需要的部分就行了,这个过程发生在组件中。
例如点击按钮:
// “详情页”
this.watch("change", prop => {
if ("chatting" === prop.chat) {
this.$chat.text("正在联系");
}
else {
this.$chat.text("联系我");
}
});
this.$chatBtn.click(_ => dispatch({ type: "chat", value: "chatting" }));
// 聊天按钮
this.watch("change", prop => {
if ("chatting" === prop.chat) {
this.$window.show();
}
else {
this.$window.hide();
}
});
this.$window.close(_ => dispatch({ type: "chat", value: "hide"}));
react-redux实际应用跟上面相差很多,不过差不多就是这个意思,把watch
换成render
就很接近了。虽然不怎么喜欢redux,但感觉也是有可取之处,那么molecule会怎样处理这种情况?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.