Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
zoneless アーキテクチャのこれまでとこれから
Search
沖総一朗
February 16, 2024
Programming
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
zoneless アーキテクチャのこれまでとこれから
沖総一朗
February 16, 2024
Other Decks in Programming
See All in Programming
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
450
sbt 2.0: takeoff
eed3si9n
0
160
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
ジョジョの世界をXRで再現する
mofurune
0
160
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
4
3.5k
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
880
R8 の設定見直しでアプリサイズ削減
andpad
0
220
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
Featured
See All Featured
BBQ
matthewcrist
90
10k
Fireside Chat
paigeccino
43
4.1k
The Cult of Friendly URLs
andyhume
79
7k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
460
Practical Orchestrator
shlominoach
192
12k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
570
Side Projects
sachag
456
43k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
640
Deep Space Network (abreviated)
tonyrice
0
370
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Marketing to machines
jonoalderson
1
5.9k
Transcript
February 16, 2024 沖 総一朗 セーフィー株式会社 zonelessアーキテクチャの これまでとこれから
© Safie Inc.| 2 Frontend Engineer s-oki-safie 沖 総一朗 Soichiro Oki
Angular好きなWebアプリケーションエンジニアです 自社で運営するビューアーアプリケーションのフロントエンド開発を担当しています Angularは今年で6年目になります
© Safie Inc.| zonelessの話の前に 3
© Safie Inc.| Angularのレンダリング 4 イベント後に更新
© Safie Inc.| Angularのレンダリング 5 非同期処理後に更新
© Safie Inc.| NgZone 6
© Safie Inc.| NgZone 7 Zoneは非同期タスクにまたがって持続する実行コンテキスト →setTimeout(), Promise.then(), addEventListener()などほとんどの非同期APIを 処理し変更検知を流してくれる
NgZoneのおかげでAngularはビューの更新タイミングが分かり、再レンダリングする ことができる https://angular.jp/guide/zone なにが問題なのか?
© Safie Inc.| 不要な変更検知 8 同期および非同期関数が実行された時に変更検知を流してくれる →モデルに変更があるかどうかは関係ない →サードパーティのライブラリで変更検知が過剰に発生する可能性がある NgZone対象外にするrunOutsideAngularなどもあるが、ルール化が難しい そうだzonelessにしよう
© Safie Inc.| zonelessにしてみよう 9
© Safie Inc.| zonelessのやり方 10 bootstrapModule bootstrapApplication bootstrapApplication(17.1以降) この2つは 同義
© Safie Inc.| これまでのzoneless 11
© Safie Inc.| Viewが更新されない 12 変更検知が走らないのでViewが更新されない
© Safie Inc.| どうするか 13 手動でDetectChanges 無事反映! →ただいちいちdetectChangesを呼ぶのは面倒 →storeを使ってasync-pipeで更新するパターンだと難しい async-pipeを応用したpush-pipeを開発
© Safie Inc.| async-pipe 14 この次の変更検知を 実施するのがzone
© Safie Inc.| push-pipe 15
© Safie Inc.| 使う側 16 いちいちdetectChangesを呼ぶ手間も省けて良さそう
© Safie Inc.| ルーティングが動かない 17 router-outlet配下のcomponentが表示されない →router-outlet配下にあるcomponentのライフサイクルイベントが動かない なぜか →detectChangesが呼ばれないとライフサイクルイベント自体が動かないから router-outletが配置されているcomponentでdetectChangesを動かす必要がある
© Safie Inc.| ルーティングをフック 18 RouterOutletが配置されているcomponentでdetectChanges まだいくつかダメなケースはありますが概ねこれで実現
© Safie Inc.| これからのzoneless 19
© Safie Inc.| これからのzoneless 20 bootstrapModule bootstrapApplication bootstrapApplication(17.1以降)
© Safie Inc.| これからのzoneless 21 bootstrapApplication(17.1以降) angular/angularのgithub参照
© Safie Inc.| ChangeDetectionSchedulerとは 22 簡単に言うと viewがdirtyになったタイミングなどで変更検知を流してくれる →markForCheck()でも変更検知が流れる zonelessでありながら手動でdetectChangesする必要がない
© Safie Inc.| provideZonelessChangeDetection 23 clickイベントなどの発生時は、viewがdirtyになるので普通に動きます
© Safie Inc.| async-pipe 24 この次の変更検知を 実施するのがzone
© Safie Inc.| async-pipeのパターンも動く 25 変数を変更しただけの場合setTimeoutだと反映されないので注意
© Safie Inc.| まとめ 26
© Safie Inc.| まとめ 27 これまでのzoneless ・手動でdetectChangesする必要があった ・動かすために様々な工夫が必要 これからのzoneless(おそらく) ・providerを差し替えるだけで動く
・おそらくデフォルトになる ・signalでもっと快適になる zonelessへのトライ自体がAngularへの理解を深める
None