Giter Site home page Giter Site logo

autils's Introduction

aUtils

aUtils for JavaScript

2015-09-11 新增EventEmit事件发布订阅

事件发布订阅插件 EventEmit 2015-09-12 利用EventEmit插件写的一个数据双向绑定的demo TwoWayDataBind. EventEmit事件插件和双向绑定demo都是使用原生JS写的, 不需要依赖jQuery等库. 不过有一定兼容性问题(其实在这个例子里稍微修改一下代码就可以兼容IE6+).

2016-02-02 18:21:54 更新发布订阅插件

新增一个函数的 aUtils.EventBase, 这个新的发布订阅是一个函数, 可以被用来继承, 类似于NodeJS里的EventEmit.

var component = function(){
	/*在这里做一些其它事情*/

	var exportsFn = function(){};
	aUtils.EventBase.implement(exports);//这样exports拥有的on/emit的发布订阅能力了, 能够提高组件的低耦合.

	var exports = new exportsFn();
	exports.emit("update", this, "else arguments");
	exports.on("change", function(arg1, arg2){
		//这是外部来的事件.
	});


	return new exports();
}

autils's People

Contributors

alanwei43 avatar allen-wei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.