Coder Social home page Coder Social logo

mobx-read's Introduction

mobx 设计的几种抽象概念:



1、observable: 响应式数据,最主要的特征是将数据变更信息上报给全局监听器,其变更会导致变更会引起指定的观察者执行其处理逻辑。mobx 使用 IObservable 接口,Atom 类加以抽象。

2、derivation: 衍生,响应式数据变更后执行的副作用函数,可以理解为实际消费 observable 的观察者。包含计算属性(ComputedValue类)、反应(Reaction类)。mobx 使用 IDerivation 接口,ComputedValue 类、Reaction 类加以抽象。

在 mobx 实现中,observable, derivation 相互持有彼此的引用。 bindDependencies


3、action: 动作,由其促使响应式数据发生变更。上一篇文章已指出,使用 observableValue 实例的 set 方法,就能促使响应式数据发生变更,action 的意义在于,使用 startBatch, endBatch 事务封装执行动作,将一组响应式数据变更复合为一,等到这组响应式数据变更完结后,才执行 derivation。在 mobx 中,action 比较单薄,因为最要紧的——将响应式数据变更上报到全局环境——这一机制由 observable 完成。在这篇文章中将不作赘述。

111


处理数据



222

how reportChanged work



333

mobx-read's People

Contributors

ihappy9ok avatar

Watchers

 avatar

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.