This file contains 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
let reddit = require('@datafire/reddit_rss').actions; | |
reddit.frontPage().then(frontPage => { | |
console.log(frontPage.feed.entries); | |
}) |
This file contains 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
paths: | |
/gifs: | |
get: | |
action: reddit_rss/subreddit | |
input: | |
subreddit: gifs |
This file contains 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
// In traditional JavaScript | |
var messages = document.getElementsByClassname('message'); | |
messages.forEach(function(message) { | |
message.className = message.className + " visible"; | |
}); | |
// With jQuery | |
$('.message').addClass('visible'); |
This file contains 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
let filenames = ['index.html', 'blog.html', 'terms.html']; | |
Promise.all(filenames.map(readFilePromise)) | |
.then(files => { | |
console.log('index:', files[0]); | |
console.log('blog:', files[1]); | |
console.log('terms:', files[2]); | |
}) |
This file contains 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
function readFilePromise(filename) { | |
if (!filename) { | |
return Promise.reject(new Error("Filename not specified")); | |
} | |
if (filename === 'index.html') { | |
return Promise.resolve('<h1>Hello!</h1>'); | |
} | |
return new Promise((resolve, reject) => {/*...*/}) | |
} |
This file contains 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
Promise.resolve() | |
.then(_ => api.deleteItem(1)) | |
.then(_ => api.deleteItem(2)) | |
.then(_ => api.deleteItem(3)) | |
.then(_ => api.deleteItem(4)) | |
.then(_ => api.deleteItem(5)); |
This file contains 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
Promise.resolve() | |
.then(_ => api.getItem(1)) | |
.then(item => { | |
item.amount++; | |
return api.updateItem(1, item); | |
}) | |
.catch(e => { | |
console.log('failed to get or update item'); | |
}) |
This file contains 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
api.getItem(1) | |
.then(item => { | |
item.amount++; | |
api.updateItem(1, item) | |
.then(update => { | |
api.deleteItem(1) | |
.then(deletion => { | |
console.log('done!'); | |
}) | |
}) |
This file contains 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
api.getItem(1) | |
.then(item => { | |
item.amount++; | |
return api.updateItem(1, item); | |
}) | |
.then(update => { | |
return api.deleteItem(1); | |
}) | |
.then(deletion => { | |
console.log('done!'); |
This file contains 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
api.getItem(1) | |
.then(item => { | |
item.amount++; | |
api.updateItem(1, item); | |
}) | |
.then(update => { | |
return api.deleteItem(1); | |
}) | |
.then(deletion => { | |
console.log('done!'); |