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
Elmが思ったより良かった話
Search
nagimaru
June 19, 2019
Technology
780
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Elmが思ったより良かった話
nagimaru
June 19, 2019
More Decks by nagimaru
See All by nagimaru
AngularでPWAやろうよ
leafia78
0
220
ElixirでWebフロントエンドは出来るのか
leafia78
1
470
Other Decks in Technology
See All in Technology
Claude Code本は、どのように執筆チームで書かれたか
oikon48
0
310
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
200
AI Made Us Faster at Solving the Wrong Problems
marceloancelmo
0
190
継続的なAIコスト最適化
bgpat
1
220
More Freedom on the Same Shared GPU Cluster: A Small Team’s Experience with vCluster
nttcom
0
140
FOSS4Gを活用した自治体業務DXの試み
470715
0
120
AIは爆速なのに、私が詰まっていた話 ― 音声入力と鳴くマスコットでボトルネックを削る
yama3133
0
530
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
180
今こそ知りたいAmplifyGen2
mkdev10
2
160
データ品質を壊しながらSnowflakeのAIに分析させてみた
kawanago
0
540
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
2
910
自律型 AI をセキュアに実装!Gemini と MIG で作る動的コード実行環境
recruitengineers
PRO
1
220
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
210
sira's awesome portfolio website redesign presentation
elsirapls
0
440
The Art of Programming - Codeland 2020
erikaheidi
57
14k
The Language of Interfaces
destraynor
162
27k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
740
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
The Cost Of JavaScript in 2023
addyosmani
55
10k
So, you think you're a good person
axbom
PRO
2
2.2k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Six Lessons from altMBA
skipperchong
29
4.5k
Transcript
2019/6/19 PWANight localhost:8080 1/19 Elmが思ってたより良かった話 Elmの紹介とElmアプリケーションでのPWA
2019/6/19 PWANight localhost:8080 2/19 About me Webフルスタック(雑⽤)エンジニア,UIデザイナー Elixir,Elm,TypeScript 神社巡り,バスケ @ngmr_mo(nagimaru)
Tomoya Ishizaka
2019/6/19 PWANight localhost:8080 3/19 Elmは余分な機能を削ぎ落とし、 さらにフレームワーク(TEA)を内包した関数型⾔語
2019/6/19 PWANight localhost:8080 4/19 TEA (The Elm Architecture) とは
2019/6/19 PWANight localhost:8080 5/19 TEAとは 引⽤: https://medium.com/@l.mugnaini/the-elm-architecture-tea-animation-3efc555e8faf の始祖とか⾔われてるやつ Redux
2019/6/19 PWANight localhost:8080 6/19 TEAとは Update Msgを受け取り、新しいModelとCmdを返す Model 状態 View
Modelを元にHTMLを返す Cmd 副作⽤を扱う仕組み。APIのレスポンスなどをMsgと共に返してくれたり。
2019/6/19 PWANight localhost:8080 7/19 TEAとは Model init : String ->
( Model, Cmd Msg ) init slug = getArticle slug -- ① slug と共にGetArticle というMsg を送信 getArticle : String -> ( Model, Cmd Msg ) getArticle slug = update (GetArticle slug) { response = Loading, slug = slug }
2019/6/19 PWANight localhost:8080 8/19 TEAとは Update update : Msg ->
Model -> ( Model, Cmd Msg ) update msg model = case msg of -- ③ Cmd が返したGotArticle というMsg と共に結果を受け取りモデル更新 GotArticle result -> case result of Ok articleData -> ( { model | response = Success articleData }, Cmd.none ) Err _ -> ( { model | response = Failure }, Cmd.none ) -- ② GetArticle を受け取ったらContentfulAPI を呼び出す(Cmd 発⾏) GetArticle slug -> ( model, Contentful.getArticle GotArticle slug )
2019/6/19 PWANight localhost:8080 9/19 TEAとは View view : Model ->
{ title : String, body : List (Html Msg) } view model = { title = "Hoge" , body = [ section [ ] [ case model.response of Loading -> p [ ] [ text "Loading..." ] Failure -> p [ ] [ text "Not Found" ] Success articleData -> -- TODO: 記事表⽰ article [ ] [ ] ] ] }
2019/6/19 PWANight localhost:8080 10/19 ElmはTEAでアプリケーションを構築するための⾔語 と⾔っても過⾔ではない (⾔語とフレームワークが密結合)
2019/6/19 PWANight localhost:8080 11/19 Elmのいいところ 基本的に実⾏時エラーが出ない 仕様が⼩さいため学習コストが極めて低い [1,2,3]===[1,2,3] がTrue *1
コンパイル早え エラーメッセージが親切すぎる 型付けに「がんばる」とか「がんばらない」とかない*2 *1 参照を考えなくて良い *2 「がんばらないTypeScript」が話題でしたね
2019/6/19 PWANight localhost:8080 12/19 Elmのつらいところ UnsafeなものをElmアプリケーションの外側に出すためにボイラープレートが 強制される(Portなど) TEA以外のフレームワークやアーキテクチャを選択できない(⾒⽅によってはメ リット) ⼩さいUIパーツに独⽴した状態を持たせられないので複雑なUIを作ろうとする
と⾟い
2019/6/19 PWANight localhost:8080 13/19 個⼈的な使い分け ハッカソンなどの使い捨てプロダクト JavaScript + React +
MobX 普段の業務 TypeScript + React + (MobX or Typeless) ⼤規模開発 TypeScript + Angular + NgRx (angular-cliが⼼強い) とにかく堅牢に⾏きたい Elm + The Elm Architecture
2019/6/19 PWANight localhost:8080 14/19 ElmでPWAをやってみよう
2019/6/19 PWANight localhost:8080 15/19 PWA with Elm $ create-elm-app pwa_app
2019/6/19 PWANight localhost:8080 16/19 PWA with Elm $ create-elm-app pwa_app
これだけでPWA対応したコードが吐き出されます
2019/6/19 PWANight localhost:8080 17/19 create-elm-appによるPWA対応 manifest.jsonが吐き出される ビルド時sw-precache-webpack-pluginによってservice-worker.jsを⽣産する ServiceWorkerをregisterしたりunregisterしたりする関数が⼊った registerServiceWorker.jsが吐き出される
2019/6/19 PWANight localhost:8080 18/19 好き勝⼿webpack.con gをいじろう $ elm-app eject
2019/6/19 PWANight localhost:8080 19/19 ありがとうございました!