eventproxy 介绍
这个世界上不存在所谓回调 函数 深度嵌套的问题。 —— Jackson Tian?
世界上本没有嵌套回调,写得 人多 了,也便有了}}}}}}}}}}}}。 —— fengmk2
EventProxy 仅仅是 一个 很轻量的工具,但是能够带来一种事件式编程的思维变化。有几个特点:
利用事件机制解耦复杂业务逻辑
移除被广为诟病的深度callback嵌套问题
将串行等待变成并行等待,提升多异步协作场景下的执行效率
友好的Error handling
无平台依赖,适合前后端,能用于浏览器和Node.js
兼容CMD,AMD以及Commo njs 模块环境
现在的,无深度嵌套的,并行的
var ep = EventProxy.create("template","data","l10n",function (template,data,l10n) {
_.template(template,l10n);
});
$.get("template",function (template) {
// something
ep.emit("template",template);
});
$.get("data",function (data) {
// something
ep.emit("data",data);
});
$.get("l10n",function (l10n) {
// something
ep.emit("l10n",l10n);
});
过去的,深度嵌套的,串行的。
var render = function (template,data) {
_.template(template,data);
};
$.get("template",function (template) {
// something
$.get("data",function (data) {
// something
$.get("l10n",function (l10n) {
// something
render(template,l10n);
});
});
});
安装
Node 用户
通过npm安装即可使用:npm install eventproxy 调用 :var EventProxy = require('eventproxy');spm
spm install eventproxy
Component
component install JacksonTian/eventproxy
网站地址 : http://html5ify.com/eventproxy
GitHub: https://github.com/JacksonTian/eventproxy
网站描述: 基于任务/事件的异步模式实现
eventproxy官方网站
官方网站: http://html5ify.com/eventproxy
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。