MobX v2.6.0 發布,一個 TFRP 編程范式的實現

jopen 8年前發布 | 8K 次閱讀 MobX TFRP FRP

 

要想知道MobX是什么,首先需要了解一下FRP是什么,FRP 的本質是,在聲明一個值的時候,同時指定他的動態行為。這個值可能是事件,也可能是數據。 FRP 有兩個重要的分支:

  • 基于 Event Stream 的 FRP
    基于 Event Stream 的 FRP 擅長于管理 Stream,可進行 Joining, splitting, merging, mapping, sampling 等等。在需要處理多個 Event Stream 的時候非常有用,但對于簡單場景來說,就過于復雜了。比如 RxJS 和 BaconJS 就屬于此類。
     
  • Transparent FRP (TFRP)
    Transparent FRP 是在背后去實現 Reactive Programming 。和 Event Stream 的 FRP 一樣,TFRP 會在需要的時候更新 View,不同的是 TFRP 不需要你定義如何 (How) 以及何時 (When) 更新。這一類型的框架有 Meter(Tracker),knockoutJS 和 EmberJS 。

接下來介紹一下Mobx 和 其他實現有什么不同:

  • 同步執行 (這樣監聽的值始終是最新的,并且調試會方便,因為沒有額外的 Promise/Async 庫引入的堆棧信息)
  • 沒有引入額外的數據結構,基于普通的 Object, Class, Array 實現 (更少學習成本,更新數據時更自然)
  • 獨立方案 (不捆綁框架,相比 Meter, EmberJS 和 VueJS 而言)

 

更新日志

  • Fixed #566: Fixed incorrect behavior of toJStoJS will now only recurse into observable object, not all objects. The new behavior is now aligned with what is suggested in the docs, but as a result the semantics changed a bit. toJSlegacy will be around for a while implementing the old behavior. See #589 for more details.
  • Fixed #571: Don't use instanceof operator. Should fix issues if MobX is included multiple times in the same bundle.
  • Fixed #576: disallow passing actions directly to autorun; as they won't be tracked by @jeffijoe
  • Extending observable objects with other observable (objects) is now explicitly forbidden, fixes #540.

 

下載

 

本站原創,轉載時保留以下信息:
本文轉自:深度開源(open-open.com)
原文地址:http://www.baiduhome.net/news/view/4c5e4a42

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!