import webpack from 'webpack'
const webpackConfig = { ... }
const webpackCompile = config => new Promise((resolve, reject) => {
webpack(config, (err, stats) => err ? reject(err) : resolve(status))
});
webpackCompile(webpackConfig)
.then((status) => {
alert('OK')
})
.catch((err) => {
alert('ERR')
})
fetch(url, opts)
.then((resp) => {
if (resp.ok) return resp;
return resp.json()
.then(json => json)
.catch(() => null)
.then(errData => {
const error = new Error(resp.statusText);
error.status = resp.status;
if (errData) error.data = errData
throw error;
})
})
.then(...)
.catch(...)
> zadd hackers 1940 "Alan Kay"
(integer) 1
> zadd hackers 1957 "Sophie Wilson"
(integer 1)
> zadd hackers 1953 "Richard Stallman"
(integer) 1
> zadd hackers 1949 "Anita Borg"
(integer) 1
> zadd hackers 1965 "Yukihiro Matsumoto"
(integer) 1
> zadd hackers 1914 "Hedy Lamarr"
(integer) 1
> zadd hackers 1916 "Claude Shannon"
(integer) 1
> zadd hackers 1969 "Linus Torvalds"
(integer) 1
> zadd hackers 1912 "Alan Turing"
(integer) 1
> zrevrange hackers 0 -1
1) "Linus Torvalds"
2) "Yukihiro Matsumoto"
3) "Sophie Wilson"
4) "Richard Stallman"
5) "Anita Borg"
6) "Alan Kay"
7) "Claude Shannon"
8) "Hedy Lamarr"
9) "Alan Turing"
config.autoload_paths << Rails.root.join('lib')