# avalon **Repository Path**: nwangwei/avalon ## Basic Information - **Project Name**: avalon - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2015-07-30 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Avalon A lightweight,high-performance and easy-to-learn JavaScript MVVM framework * Avalon now has 3 versions: `avalon.js` for IE6+ and modern browsers (including Webkit/Chromium based browsers), `avalon.modern.js` for IE10+ and HTML5 standard browsers and `avalon.mobile.js`, which added `Touch Event`, `Pointer Event` and `fastclick` support for mobile devices. For requirejs or AMD-like loader, use the corresponding shim version. * The component libraries are now maintained by [Qunar UED(Chinese page)](http://ued.qunar.com/). First here are the three pillars: 1. [mmRouter](https://github.com/RubyLouvre/mmRouter) for router, 2. [mmAnimate](https://github.com/RubyLouvre/mmAnimate) for animation, 3. [mmRequest](https://github.com/RubyLouvre/mmRequest) for AJAX utils; and the UI component OniUI, you can check it out [at here](https://github.com/RubyLouvre/avalon.oniui) * The test cases are in an individual repository: [avalon.test](https://github.com/RubyLouvre/avalon.test) ## HomePage [http://avalonjs.github.io/](http://avalonjs.github.io/) [Fork it](https://github.com/avalonjs/avalonjs.github.io) ##nuget [nuget](https://www.nuget.org/packages/avalon/1.45.0) ##Loader Avalon uses a AMD-style loader. If you like Node.js's CommonJS loader, you can use [this tools](https://github.com/ilife5/cat) this tool to converts AMD to CommonJS. ## Advantages One absolute advantage is that the framework eliminates couplings and frees developers from varies of complex event handling. For example, one state could be effected by the order of several events and their additional arguments, making the logic extremely complex and fragile without using MVC (including MVVM) framework and might usually maintain lots of mutuality logics which can easily cause bugs at the same time. By using these sort of framework, one can totally reduce the difficulty of app development, and make the code more robust. Besides, it also frees developers from the repeated tasks, like `{value}` directive can simply replace `$(selector).text(value)`, what's more, some common directive can also implement some logics swiftly. Here are some of the benefits: * Easy to use. Just add binding code in HTML, then define ViewModels in JavaScript code, finally invoke `avalon.scan()`, enjoy! * Compatible with IE6+ (*Very Important* in China at present / Others: KnockoutJS(IE6+), AngularJS(IE9+), EmberJS(IE8+), WinJS(IE9+)), For more efficient and edge developers, use: `avalon.modern`. * No dependencies, less than 5000 lines of code and at 50KiB size of compressed code. * Support filter function using pipe symbol `|`, easy for output formatting. * Partial refreshing are accurated to every text/attribute node. * No need to use selector, as the node to manipulate has all been binded and cached to the view refreshing function at the initial scanning procedure. * You need to write DOM manipulation code slightly, either. * By using cascading render mechanism like CSS, ViewModels can render their views alternately. * While removing the node, the framework can detach the watching function of the corresponding views, reducing memory usage. * *Data Manipulation as DOM Manipulation*, actions on ViewModels will all be synchronized to the relevant Views and Models. * Ships with a built-in AMD loader. ## To compress JavaScript files, run: ```sh java -jar compiler.jar --js avalon.js --js_output_file avalon.min.js java -jar compiler.jar --js avalon.modern.js --js_output_file avalon.modern.min.js java -jar compiler.jar --js avalon.mobile.js --js_output_file avalon.mobile.min.js ``` Demo: ```html
First name:
Last name:
Hello,
First name:
Last name:
Hello,
MVVM最先使用是在WPF,对于微软来说是从WinForm的MVP和其余的MVC衍生而来, 比MVP/MVC做到更多的就是数据的Binding, 使得数据的变化能即时以增量的形式反馈到View上。 同理的实现好像还有iOS delegate,为MVC提供类似binding的Publish/Subscribe功能