niepan

1.0.9 • Public • Published

niepan

Gitter Gitter

var np = niepan();

event

np.sub('xyz',function(){
  console.log('xyz is happend');
})
np.pub('xyz');
 
var li1 = niepan(document.getElementById('li1'));
console.log(li1);
li1.sub('click',function(){
  console.log('clicked li1,this event could be pubed all the time');
});
 
var body= niepan(document.body);
console.log(body);
body.sub('click',function(){
  console.log('clicked body,this event would be pubed only one time');
},true);

It will throw a error when define a niepan for the same element moe than one time;

var input = niepan(document.getElementById('input1'));
var input = niepan(document.getElementById('input1'));//ERROR

http request

np.request({
  url:'https://server/xxx',
  success:function(res){
    console.log(res);
  }
});

two-way data-binding

<input id="input1" type="text" value="" watch="name" placeholder="place input your name" />
var input1 = niepan(document.getElementById('input1'));
input1.sub('input',function(evt){
  console.log(input1.$data.name);
});

Readme

Keywords

Package Sidebar

Install

npm i niepan

Weekly Downloads

0

Version

1.0.9

License

ISC

Unpacked Size

77.2 kB

Total Files

32

Last publish

Collaborators

  • ygg