Last active
August 29, 2015 14:22
-
-
Save mezigh/e535bbbb009d51203898 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/jiwiqu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.22/rx.all.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<meta name="description" content="Rx JS Intro"> | |
<style id="jsbin-css"> | |
body { | |
background: lightblue; | |
} | |
#movable { | |
display: block; | |
position:absolute; | |
top:0; | |
left:0; | |
font-family: sans-serif | |
} | |
#movable>p { | |
background: red; | |
padding:.4em; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="movable"> | |
<p>MOVE</p> | |
</div> | |
<script id="jsbin-javascript"> | |
console.clear(); | |
function Product (productName,productPrice) { | |
this.name = productName; | |
this.price = productPrice; | |
} | |
var products = [new Product('laptop',1000), new Product('desktop',1500)]; | |
var Observable = Rx.Observable.create(function (observer) { | |
// Yield a single value and complete | |
observer.onNext(321); | |
observer.onCompleted(); | |
// Any cleanup logic might go here | |
return function () { | |
console.log('disposed'); | |
}; | |
}); | |
var Obs = Rx.Observable.range(1, 5); | |
var ProdObs = Rx.Observable.from(products); | |
var subscription = ProdObs.subscribe( | |
function (prod) { console.log('onNext: '+ prod.name); }, | |
function (e) { console.log('onError: %s', e); }, | |
function () { console.log('onCompleted'); } | |
); | |
subscription.dispose(); | |
// console.log(products); | |
/*addEventListener('mousemove', function (e) { | |
document.getElementById("movable").style.top = e.clientY+"px"; | |
document.getElementById("movable").style.left = e.clientX+"px"; | |
}); | |
addEventListener('click', function (e) { | |
console.log(e.clientX); | |
});*/ | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
background: lightblue; | |
} | |
#movable { | |
display: block; | |
position:absolute; | |
top:0; | |
left:0; | |
font-family: sans-serif | |
} | |
#movable>p { | |
background: red; | |
padding:.4em; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">console.clear(); | |
function Product (productName,productPrice) { | |
this.name = productName; | |
this.price = productPrice; | |
} | |
var products = [new Product('laptop',1000), new Product('desktop',1500)]; | |
var Observable = Rx.Observable.create(function (observer) { | |
// Yield a single value and complete | |
observer.onNext(321); | |
observer.onCompleted(); | |
// Any cleanup logic might go here | |
return function () { | |
console.log('disposed'); | |
}; | |
}); | |
var Obs = Rx.Observable.range(1, 5); | |
var ProdObs = Rx.Observable.from(products); | |
var subscription = ProdObs.subscribe( | |
function (prod) { console.log('onNext: '+ prod.name); }, | |
function (e) { console.log('onError: %s', e); }, | |
function () { console.log('onCompleted'); } | |
); | |
subscription.dispose(); | |
// console.log(products); | |
/*addEventListener('mousemove', function (e) { | |
document.getElementById("movable").style.top = e.clientY+"px"; | |
document.getElementById("movable").style.left = e.clientX+"px"; | |
}); | |
addEventListener('click', function (e) { | |
console.log(e.clientX); | |
});*/ | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: lightblue; | |
} | |
#movable { | |
display: block; | |
position:absolute; | |
top:0; | |
left:0; | |
font-family: sans-serif | |
} | |
#movable>p { | |
background: red; | |
padding:.4em; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
function Product (productName,productPrice) { | |
this.name = productName; | |
this.price = productPrice; | |
} | |
var products = [new Product('laptop',1000), new Product('desktop',1500)]; | |
var Observable = Rx.Observable.create(function (observer) { | |
// Yield a single value and complete | |
observer.onNext(321); | |
observer.onCompleted(); | |
// Any cleanup logic might go here | |
return function () { | |
console.log('disposed'); | |
}; | |
}); | |
var Obs = Rx.Observable.range(1, 5); | |
var ProdObs = Rx.Observable.from(products); | |
var subscription = ProdObs.subscribe( | |
function (prod) { console.log('onNext: '+ prod.name); }, | |
function (e) { console.log('onError: %s', e); }, | |
function () { console.log('onCompleted'); } | |
); | |
subscription.dispose(); | |
// console.log(products); | |
/*addEventListener('mousemove', function (e) { | |
document.getElementById("movable").style.top = e.clientY+"px"; | |
document.getElementById("movable").style.left = e.clientX+"px"; | |
}); | |
addEventListener('click', function (e) { | |
console.log(e.clientX); | |
});*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment