GithubHelp home page GithubHelp logo

inshua / d2js Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 10.0 29.06 MB

d2js - 前后端web数据框架; jssp - Javascript Server Page;

License: MIT License

JavaScript 47.64% HTML 18.14% Java 5.34% CSS 28.87% Batchfile 0.01%

d2js's People

Contributors

inshua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

d2js's Issues

molecule 如何处理“全局”数据(状态)?

淘宝“宝贝详情页”上,有个跟卖家聊天的按钮,点击之后可以跟卖家直接聊天。
现在考虑这样一个场景,如果点击聊天之后,卖家下面的“联系我”变成“正在联系”,然后弹出聊天窗口,关闭聊天窗口后恢复成“联系我”。

从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会怎样处理这种情况?

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.