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
Planning for next syntagme.js #gotandajs
Search
mizuki_r
July 14, 2017
Technology
0
360
Planning for next syntagme.js #gotandajs
2017/07/14 #gotandajsの発表資料です
mizuki_r
July 14, 2017
Tweet
Share
More Decks by mizuki_r
See All by mizuki_r
税理士ドットコムの 技術的挑戦 #tapioca_lt
rymizuki
0
250
PHPを始めて1年、レガシーシステムにどう向き合っているか #phpstudy
rymizuki
1
600
モダンとレガシー #gotandaem
rymizuki
0
500
Vuexに型を付けるパターンを調べた #gotandajs
rymizuki
0
110
DockerでNodeの開発は厳しいのか? #gotandajs
rymizuki
3
340
マネージャー!きみは何者だ! #gotandaem
rymizuki
0
1.6k
物語を楽しむための物語論
rymizuki
0
480
失敗と向き合う
rymizuki
0
1.2k
社内勉強会と組織の成長を考える
rymizuki
1
2.5k
Other Decks in Technology
See All in Technology
やってやろうじゃないかメカアジャイル! / Let's do it, mechanical agile!
psj59129
1
670
プログラム検証入門
riru
6
870
実務における脅威モデリングを考えよう
nikinusu
0
630
Google CloudのLLM活用の選択肢を広げるVertex AIのパートナーモデル
nayuts
0
130
再考 アクターモデル/ reconsider actor model
ytake
0
360
ナレッジグラフとLLMの相互利用
koujikozaki
0
420
プロダクトエンジニアを支えるための開発生産性向上施策
tsukakei
0
140
リアルお遍路+SORACOM IoT
ozk009
1
140
なにもしてないのにNew Relicのデータ転送量が増えていたときに確認したこと
tk3fftk
2
230
Tricentisにおけるテスト自動化へのAI活用ご紹介/20240910Shunsuke Katakura
shift_evolve
0
200
「認証認可」という体験をデザインする ~Nekko Cloud認証認可基盤計画
logica0419
2
440
内製化を目指す事業会社が、システム開発会社と共に進める「開発生産性改善」の取り組み事例 #devsumi
yuwji
0
100
Featured
See All Featured
Robots, Beer and Maslow
schacon
PRO
157
8.2k
Atom: Resistance is Futile
akmur
261
25k
From Idea to $5000 a Month in 5 Months
shpigford
379
46k
The Language of Interfaces
destraynor
153
23k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
43
2k
How to name files
jennybc
75
98k
A Tale of Four Properties
chriscoyier
155
22k
Building Adaptive Systems
keathley
36
2.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
36
2.1k
The Art of Programming - Codeland 2020
erikaheidi
48
13k
Designing for Performance
lara
604
68k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
5
480
Transcript
Planning for next syntagmejs 2017/07/14 Gotanda.js #8 @mizuki_r
@mizuki_r • シニアフロントエンドエンジニア • エンジニア 2 #javascript #gotandajs #meguroes #perl
#kichijojipm 五反田のM社で位置ゲー開発に携わる。 最近まじでJSどころかコードをほとん ど書いてない生活。 about me こんな人です
本日のお題
最近コード書いてないな… (´・ω・`)
なんか書くか (´・ω・`)
… (´・ω・`)
なに書こう… (´・ω・`)
よし、なに書くか考えよう! (๑•̀Ŷ•́๑)ソレダ!
SyntagmeJS アップデートを計画する話
SyntagmeJS
SyntagmeJSて? • https://github.com/rymizuki/syntagmejs • ࣗ࡞ͷFluxϑϨʔϜϫʔΫ • 2016/04/27͔ΒฐࣾͰͬͯ·͢
SyntagmeJSて? • AngularJS(1.x)Ͱ͑Δ • Vueͱ͔ʹҠ২͍͢͠ • reduxΛઆ໌͢Δͷ͕ΊΜͲ͍ • fluxͷงғؾͬͯΕͳΜͱͳ͑͘Δ
const app = syntagme() app.reducer(({ action }, state = {})
=> { switch (actio.type) { case 'FETCH': return _.defaults({ message: null }, state) case 'FETCH_RESOLVE': return _.defaults({ message: action.message }, state) case 'FETCH_REJECT': return _.defaults({ error: action.rejection }, state) } }) app.listen() app.subscribe((state) => { console.log('state', state) }) app.ac('FETCH', () => { return http.get('/api/messages/greeting') .then(({ body }) => { return { message: body.message } }) })
1年運用してみて
思うところ • reducer…? • ac…? • ͦΕͳΜͰactionCreatorͰॻ͘ͷʁ • ͦΕͳΜͰreducerͰॻ͘ͷʁ
思うところ • fluxͷ֓ཁ͍ͬͯͯɺ࣮ࡍॻ͜͏ͱ͢ Δͱʮ͋Εʁʯʮ͓ʁʯͱͳΔ…
思うところ • reducerॻ͘ͷΊΜͲ͍ • actionCreatorͳͷ͔actionͳͷ͔Կͳͷ͔ • actionCreator͔Βreducer·ͰͷྲྀΕ͕Θ͔Γʹ͘ ͍ • action.typeͷtypoͭΒ
改善したい!
改善方針 • ߟ͑Δ࣌ؒͷݮ • ॻ࣌ؒ͘ͷݮ • σόοά࣌ؒͷݮ
考える時間の削減 • ·ͣɺԿʹ͕͔͔࣌ؒΔͷ͔ʁΛΔ • UIΛ࡞ΔϑϩʔΛݟΔ • Α͘಄Λֻ͔ΔϙΠϯτͷѲ
考える時間を削減
考える時間の削減 • ·ͣɺԿʹ͕͔͔࣌ؒΔͷ͔ʁΛΔ • UIΛ࡞ΔϑϩʔΛݟΔ • Α͘಄Λֻ͔ΔϙΠϯτͷѲ
UIを作るときのフロー • UIͱը໘ભҠΛϖʔύʔϓϩτ • ͜ͷஈ֊ͰϢʔβ͕Ͳ͏͍͏ʮߦಈʯΛΞϓϦͰߦ͏͔͕ચ͍ग़ͤΔ • HTMLʹใຒΊࠐΈɺը໘ભҠΛߏங • ϕλͩͬͨΓಈతͩͬͨΓɺͱʹ͔͘ભҠͰ͖Δ͜ͱ͕ॏཁ •
Γͳ͕ΒreducerʹدͤΔใʹΛ͚ͭͯ͘ • ભҠʹඞཁͳΞΫγϣϯΛΈ࢝ΊΔ • ಈతͳσʔλΛreducerʹدͤΔ • stateʹ͋Δͷɺແ͍ͷ͔ΒAPIΛઃܭͨ͠Γ߹ͨ͠Γͯ͠actionCreatorͷ෦Λ Ή • શମͷΞʔΩςΫνϟΛ͑Δ • actionCreatorͰAPI͔ΒσʔλΛड͚औΓɺreducerͰॲཧ͢Δ
syntagme的には • actionCreator͕ಡΈऔΓʹ͍͘ • Կʹରͯ͠ԿΛ͍ͯ͠Δͷ͔ • ߦಈͷϦετઌʹ࡞ΕΔͷʹɺ࣮ʮߦಈʯ ͷ༰͕ओମ • ໊͕ؔͦͦΘ͔Γʹ͍͘
• actionCreatorΛҙຯ͢Δacɺॲཧʮdispatchʯ • reducerɺॲཧʮregisterʯ
ならば、こうしよう • ΞϓϦʹରͯ͠ͷʮߦಈʯͰ͋Δ͜ͱΛࣔ͢ • app.action(‘FETCH’) Έ͍ͨͳ • ࣮ߦͱొͷI/FΛ͚Δ • ໊ࢺͱಈࢺΛ͍͚Δ
• ໊ࢺʮregisterʯ • ಈࢺʮdispatchʯ
そして、こうなる app.actionCreator('FETCH', ({ key }) => { return http.get(`/api/messages/${ key
}`) .then(({ body }) => { return { message: body.message } }) }) app.reducer(({ action }, state = {}) => { switch (actio.type) { case 'FETCH': return _.defaults({ message: null }, state) case 'FETCH_RESOLVE': return _.defaults({ message: action.message }, state) case 'FETCH_REJECT': return _.defaults({ error: action.rejection }, state) } }) app.listen() app.action('FETCH', { key: 'greeting' })
書く時間の削減
いま app.reducer(({ action }, state = {}) => { switch
(actio.type) { case 'FETCH': return _.defaults({ message: null }, state) case 'FETCH_RESOLVE': return _.defaults({ message: action.message }, state) case 'FETCH_REJECT': return _.defaults({ error: action.rejection }, state) } })
めんどくさい • switch-caseจ • (payload, state = {}) • _.defaults,
Object.assign • ෮͞ΕΔίʔυ͕ଟ͍
削ろう app.reducer({ FETCH ({ action }) { return { message:
null } }, FETCH_RESOLVE ({ action }) { return { message: action.message } }, FETCH_REJECT ({ action }) { return { error: action.rejection } } })
デバッグ時間を削減
ハマりどころ • Τϥʔग़ͯͳ͍ͷʹԿނ͔State͕ߋ৽͞Ε ͳ͍ • app.ac(‘FETH’) ←͜͜Ͱtypo • case ‘FECH’
← ͜͜Ͱtypo
謎にハマるのは大体typo • dispatch, subscribeͰconsole.logు͍ͯΔ • devToolsԽ͠Α͏ͱͯ͠৺ંΕͨ • typoʹͳ͔ͳ͔ؾ͚ͮແ͍ • ͨ͘͞ΜActionు͍ͯΔ͠
• reducerίʔυଟ͍͠ • TypeͷࣙॻΛ࡞Δͷ໘… • ໘(´ɾТɾʆ)
ぁあ〜 せめてどっちでtypoしてるの かさえわかれば〜〜
ん… まてよ…
app.action('FETCH')
validationできるじゃん!
まとめ
こんな感じになりました const app = syntagme() app.actionCreator('FETCH', ({ key })
=> { return http.get(`/api/messages/${ key }`) .then(({ body }) => { return { message: body.message } }) }) app.reducer({ FETCH ({ action }) { return { message: null } }, FETCH_RESOLVE ({ action }) { return { message: action.message } }, FETCH_REJECT ({ action }) { return { error: action.rejection } }, }) app.listen() app.subscribe((state) => { console.log('state', state) }) app.action('FETCH', { key: 'greeting' })
今日のお話 • ࣗ࡞FluxϑϨʔϜϫʔΫͷվमͷ͓Λ͠·ͨ͠ • ීஈߟ͑ͯΔ͚Ͳ͋·ΓݴޠԽͯ͠ͳ͍෦Λ ͯ͠Έͨ • Θ͔ͬͨͳ…ʁ • ݁ہίʔυॻ͍ͯͶ͑ͷ͔Α͍ͬͯ͏
今後の展望 • ͜ΕΛݩʹίʔυΛॻ͘ • ͍ͭͰʹlistenࣗಈԽ͍ͨ͠ • ࢠΠϯελϯε࡞ͬͯ࿈ܞͰ͖ΔΑ͏ʹ͍ͨ͠ • VuePluginͱ͔࡞Γ͍ͨ
ご清聴 ありがとうございました \\\\(۶•̀ᴗ•́)۶////