eventproxy

编程之家收集整理的这个编程导航主要介绍了eventproxy编程之家,现在分享给大家,也给大家做个参考。

eventproxy

eventproxy 介绍

这个世界上不存在所谓回调函数深度嵌套的问题。 —— Jackson Tian 

世界上本没有嵌套回调,写得人多了,也便有了}}}}}}}}}}}}。 —— fengmk2

EventProxy 仅仅是一个很轻量的工具,但是能够带来一种事件式编程的思维变化。有几个特点:

利用事件机制解耦复杂业务逻辑

移除被广为诟病的深度callback嵌套问题

将串行等待变成并行等待,提升多异步协作场景下的执行效率

友好的Error handling

无平台依赖,适合前后端,能用于浏览器和Node.js

兼容CMD,AMD以及Commonjs模块环境

现在的,无深度嵌套的,并行的

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

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

相关文章

johnny-five,Bocoup 的 JavaScript 机器和物联网编程框架
WePY,一款让小程序支持组件化开发的框架
Deep playground,神经网络的交互式可视化,使用d3.js和TypeS...
ShareDB,用于并发编辑系统的前端数据库
RxJS,RxJS 是使用 Observables 的响应式编程的库
egg-react-ssr,最小而美的Egg + React + SSR 服务端渲染应用...