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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Vite+ Unified Toolchain for the Web
naokihaba
0
240
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
240
Modding RubyKaigi for Myself
yui_knk
0
920
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.3k
Claspは野良GASの夢をみるか
takter00
0
180
Oxcを導入して開発体験が向上した話
yug1224
4
310
Inside Stream API
skrb
1
680
Contextとはなにか
chiroruxx
0
290
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
450
AIで効率化できた業務・日常
ochtum
0
120
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
880
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
220
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
440
Building Applications with DynamoDB
mza
96
7.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
390
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
160
AI: The stuff that nobody shows you
jnunemaker
PRO
8
700
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
Test your architecture with Archunit
thirion
1
2.3k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
280
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