Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
fetchのCancel Abort方法標準化の変遷 / A History of Cance...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
tipo159
March 29, 2018
Programming
560
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
fetchのCancel Abort方法標準化の変遷 / A History of Cancel Abort Method Standard
・Cancelable Promise
・AbortController
・Browserの対応状況
・Node.jsの対応状況
tipo159
March 29, 2018
More Decks by tipo159
See All by tipo159
Type-safe front-end development using Rust/Rustを使った型安全なフロントエンド開発
tipo159
0
510
ReasonReactとReactのAPIの違い / The Difference between ReasonReact API and React API
tipo159
2
590
REASONの紹介 / Introductory talk about REASON
tipo159
1
420
PWAで何ができるようになるのか / What does PWA do
tipo159
1
1k
HNPWAの紹介 / Introductory talk about HNPWA
tipo159
2
680
ES2015 Proxyを使ってみた / Introductory talk about ES2015 Proxy
tipo159
1
680
Webコンポーネント関連の最新動向 / Recent Topics on Web Components
tipo159
0
660
SlackはどうやってBrowserViewに乗り換えたのか / How Slack move from webview to BrowserView
tipo159
2
4.4k
コンポーネント再利用ってどこまでするの? / How to reuse components
tipo159
0
940
Other Decks in Programming
See All in Programming
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
530
Modding RubyKaigi for Myself
yui_knk
0
920
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
220
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
530
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.4k
スマートグラスで並列バイブコーディング
hyshu
0
120
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
210
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
170
技術記事、 専門家としてのプログラマ、 言語化
mizchi
4
1.8k
Contextとはなにか
chiroruxx
0
290
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
2
980
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
220
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
390
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
970
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
Unsuck your backbone
ammeep
672
58k
GitHub's CSS Performance
jonrohan
1033
470k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
sira's awesome portfolio website redesign presentation
elsirapls
0
280
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
How to Ace a Technical Interview
jacobian
281
24k
Transcript
fetchͷCancel/Abortํ๏ඪ४Խͷมભ Meguro.es #14 2018.3.29 tipo159
ΞδΣϯμ • Cancelable Promise (2015.4.10 - 2016.12.16) • AbortController (2017.1.5
- ) • BrowserͷରԠঢ়گ • Node.jsͷରԠঢ়گ 2
Cancelable Promise (2015.4.10 - 2016.12.16) • JavaScriptͷPromise༷ͷՃ • ओͳ༰ •
cancelΛresolve, rejectͱҧ͏ୈ3ͷঢ়ଶͱͯ͠Ճ • .NETͰΘΕ͍ͯͨCancel TokenΛͬͯΩϟϯηϧ • Domenic Denicola(Googleࣾһ)͕ɼ2016.12.16ʹGoogle ෦ͷରͷͨΊऔΓԼ͛(ৄࡉෆ໌) https://github.com/tc39/proposal-cancelable-promises 3
Cancelable Promiseͷαϯϓϧ async function f(cancelToken) { await a(); cancelToken.cancelIfRequested(); await
b(); } const ct = new CancelToken(cancel => { cancelButton.onclick = cancel; }); f(ct); // NOTE: will be canceled if they click the cancel button 4
AbortController (2017.1.5 - ) • ࠷ॳPromise༷ͷՃΛࢦ͍͕ͯͨ͠ɼDOM༷ ʹՃ͞Εͨ • ओͳ༰ •
AbortControllerΦϒδΣΫτΛͬͯΞϘʔτ • PromiseͷػೳՃͳ͠ • fetchҎ֎ʹద༻Մೳ • WHATWGͷDOM༷ʹՃࡁΈ https://dom.spec.whatwg.org/ 5
AbortControllerͷྫ var controller = new AbortController(); var signal = controller.signal;
var downloadBtn = document.querySelector('.download'); var abortBtn = document.querySelector('.abort'); downloadBtn.addEventListener('click', fetchVideo); abortBtn.addEventListener('click', function() { controller.abort(); console.log('Download aborted'); }); function fetchVideo() { ... fetch(url, {signal}).then(function(response) { ... }).catch(function(e) { reports.textContent = 'Download error: ' + e.message; }) } 6
BrowserͷରԠঢ়گ • αϙʔτࡁΈ • Chrome 66 • Edge 16 •
Firefox 57 • ະαϙʔτ • Safari (Technology Preview 42 2017.10.18ʙ ਖ਼ࣜαϙʔτະ) 7
Node.jsͷରԠঢ়گ • Node.jsʹDOMؔ࿈API͕ͳ͍ͨΊ༻ෆՄ • polyfillΛ͑༻Մೳ https://www.npmjs.com/package/abortcontroller-polyfill 8