Skip to content

Instantly share code, notes, and snippets.

View codemilli's full-sized avatar
😇
Hooked on React Hooks

codemilli codemilli

😇
Hooked on React Hooks
  • Zemilli Design Studio
  • Seoul, South Korea
  • X @codemilli
View GitHub Profile
var observableStream = Rx.Observable.create(function (observer) {
var url1 = 'http://hello-universe.com';
var url2 = 'http://hello-world.com';
var defaultValue = {};
observer.onNext(defaultValue);
$.get(url1).then(function(data) {
observer.onNext(data);
return $.get(url2);
var PromiseArray = [];
el.addEventListener('scroll', function(e) {
PromiseArray.push(new Promise(...));
forEachForPromise();
});
function forEachForPromises() {
PromiseArray.filter(function(promise) {
promise.then(function(data) {
$.get('http://get-user-info.com').then(function(user) {
if (user.didPay) {
showSomethingCool();
}
});
el.addEventListener('scrollWhenScrollNotAtTop', realCallback);
$.ajax('http://get-user-info.com').ifUserDidPay(showSomethingColl);
{"answers":["function(console) {\n\tvar names = [\"Ben\", \"Jafar\", \"Matt\", \"Priya\", \"Brian\"],\n\t\tcounter;\n\n\tfor(counter = 0; counter < names.length; counter++) {\n\t\tconsole.log(names[counter]);\n\t}\n}\n\t\t","function(console) {\n\tvar names = [\"Ben\", \"Jafar\", \"Matt\", \"Priya\", \"Brian\"];\n\n\tnames.forEach(function(name) {\n\t\tconsole.log(name);\n\t});\n}\n\t\t","function() {\n\tvar newReleases = [\n\t\t{\n\t\t\t\"id\": 70111470,\n\t\t\t\"title\": \"Die Hard\",\n\t\t\t\"boxart\": \"http://cdn-0.nflximg.com/images/2891/DieHard.jpg\",\n\t\t\t\"uri\": \"http://api.netflix.com/catalog/titles/movies/70111470\",\n\t\t\t\"rating\": [4.0],\n\t\t\t\"bookmark\": []\n\t\t},\n\t\t{\n\t\t\t\"id\": 654356453,\n\t\t\t\"title\": \"Bad Boys\",\n\t\t\t\"boxart\": \"http://cdn-0.nflximg.com/images/2891/BadBoys.jpg\",\n\t\t\t\"uri\": \"http://api.netflix.com/catalog/titles/movies/70111470\",\n\t\t\t\"rating\": [5.0],\n\t\t\t\"bookmark\": [{ id: 432534, time: 65876586 }]\n\t\t},\n\t\t{\n\t\t\t\"id\": 654
var btn = document.getElementById('button');
btn.addEventListener('click', function () {
if (window.__VALID_USER__) {
console.log('Hello, Universe');
}
});
el.addEventListener('scroll', function () {
if (pageYOffset !== 0) {
realCallback();
}
});
el.addEventListener('touchmove', function () {
if (pageYOffset !== 0) {
realCallback();
}
var arr = [1, 2, 3, 4, 5, 6];
var filteredArr = arr.filter(function(item) {
return item % 2 === 0;
});
var mappedFilteredArr = filteredArr.map(function (item) {
return item * 2;
});
var btn = document.getElementById('button');
btn.addEventListener('click', function () {
console.log('Hello, Universe');
});
function listen(element, eventName) {
return new Observable(observer => {
// Create an event handler which sends data to the sink
let handler = event => observer.next(event);
// Attach the event handler
element.addEventListener(eventName, handler, true);
// Return a function which will cancel the event stream
return () => {