zoukankan      html  css  js  c++  java
  • MobX响应式编程库

    MobX

    https://mobx.js.org/

    https://github.com/mobxjs/mobx

    MobX is a battle tested library that makes state management simple and scalable by transparently applying functional reactive programming (TFRP). The philosophy behind MobX is very simple:

    Anything that can be derived from the application state, should be derived. Automatically.

    which includes the UI, data serialization, server communication, etc.

     CORE API

    https://mobx.js.org/refguide/api.html

    EXAMPLE

    https://mobx.js.org/refguide/object.html

    import {observable, autorun, action} from "mobx";
    
    var person = observable({
        // observable properties:
        name: "John",
        age: 42,
        showAge: false,
    
        // computed property:
        get labelText() {
            return this.showAge ? `${this.name} (age: ${this.age})` : this.name;
        },
    
        // action:
        setAge: action(function(age) {
            this.age = age;
        })
    });
    
    // object properties don't expose an 'observe' method,
    // but don't worry, 'mobx.autorun' is even more powerful
    autorun(() => console.log(person.labelText));
    
    person.name = "Dave";
    // prints: 'Dave'
    
    person.setAge(21);
    // etc

    参考

    https://mobx.js.org/getting-started.html

    https://mobx.js.org/

  • 相关阅读:
    二阶段任务分配
    二阶段12.2
    针对提出的意见的改进
    一阶段spring(小呆呆)团队评分
    搜狗输入法使用感受
    省呱呱典型用户和用户场景
    省呱呱意见评论
    11/21
    11/20小组计划
    11/19小组计划
  • 原文地址:https://www.cnblogs.com/lightsong/p/8232688.html
Copyright © 2011-2022 走看看