JavaScript MVC 框架,RegularJS v0.3.0 發布
RegularJS v0.3.0 發布,此版本是 v0.0.1 版本以來最大的更新版本,引入了一些新特性:
-
The default Syntax changed from
{{}}
to{}
now. but you can return to old syntax use
Regular.config({END: '}}', BEGIN: '{{'})
-
Two-way filter is introduced . see reference for detail . It is used to control the flow from view back to model. you can combine it with
r-model
to realize some complex binding. -
prevent the safe error. like nested undefined error. for example
{blog.title}
won't throw' read title of undefined 'error now. -
Unified
{#include}
andtransclude
. see reference for detail. , you can use transclude content in{#include}
now 。 -
add
component.$mute
to disable a component .$inject(false)
to remove component from document. you can usecomponent.$mute(true).$inject(false)
to compeletely remove a component from document now. -
... and fixing some bug
看到 regular 的名字就能感受到撲面而來的山寨味,在開始前,我還是要說明下regularjs出現絕對不僅僅是作者的造輪子情緒泛濫的結果
Angularjs的火爆以及它的小伙伴們
Angularjs從 12年開始開始火爆起來, 數據驅動的業務實現方式也由此深入人心, 它的數據更新策略基于臟檢查,在明確內部的生命周期后在數據綁定的使用上是最為靈活的(即這種方式不介意是何種方式促使數據改變,而只關心數據改變的結 果),作者本人以及周圍的小伙伴也開始為之著迷. 隨著使用的深入, 發現angularjs的強大特性也引出了一些無法攻克的不足:
-
由于本身生命周期的強約束,難以與其它框架公用
-
入門容易,深入難 —— 想想directive一個feature就涉及到的 postlink prelink controller compile scope等等概念.
-
模板的邏輯實現依賴的是directive(ng-repeat, ng-if etc..),即最小邏輯顆粒是節點, 與常規的模板自由度上還是有較大差異.
-
FOUC(Flash of unstyled content), 因為angular是先通過瀏覽器(innerHTML)生成了dom,再后置link來產生真正需要的元素,所以會導致內容閃動.regular也沒有 完美的解決問題(因為內容仍然是前端render的),但是可以保證進入文檔的節點就是預期的節點
除此之外,Angularjs的核心是scope對象, 業務的實現大部分都是在scope上動態添加函數或屬性. 也有人提出整個controller的寫法缺乏約束性,這個時候angular-classy出現, 它將原本因掛載在scope上的業務邏輯轉移到構造函數原型的形式, 減少了靈活度,但是更有約束性, 這也給了regular很大靈感.
在angular大行其道的時期也激勵產生了很多框架,比如vue.js、avalon.js、reactive等
等優秀的框架,它們解決了一些問題, 比如avalon.js利用defineProperty實現了數據get-set的代理
并利用VB實現了ie6的兼容(當然數組還是wrap), 但總體來講基于dom實現的新秀們還是缺少足夠的差異化(代碼量的減少并不是最核心的部分)。
來自:http://www.oschina.net/news/59169/regularjs-0-3-0