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
Inside Bdash
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Kazuhito Hokamura
March 16, 2017
Technology
820
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Inside Bdash
Kazuhito Hokamura
March 16, 2017
More Decks by Kazuhito Hokamura
See All by Kazuhito Hokamura
TypeScriptとGraphQLで実現する 型安全なAPI実装 / TSKaigi 2024
hokaccha
5
5.1k
Kotlin製のGraphQLサーバーをNode.jsでモジュラモノリス化している話
hokaccha
0
3.8k
GraphQLの負債と向き合うためにやっていること
hokaccha
2
1.6k
ユビーのアーキテクチャに対する取り組み
hokaccha
1
490
RailsエンジニアのためのNext.js入門
hokaccha
7
22k
Cookpad Summer Internship 2021 Web Frontend
hokaccha
0
7.4k
巨大なモノリシック Rails アプリケーションの マイクロサービス化戦略 / 2019 microservices in cookpad
hokaccha
3
4.1k
巨大なRailsアプリケーションを「普通」にするための取り組み
hokaccha
1
1.1k
Web Frontend Improvement in Cookpad
hokaccha
1
1.2k
Other Decks in Technology
See All in Technology
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development with AI-DLC
yoshidashingo
0
140
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
360
TypeScript Compiler APIとPHP-Parserを活用し、TypeScriptとPHPで型を共有する
shuta13
0
360
先取りMaven4 ~16年ぶりのメジャーアップデート、その進化とは?~
ogiwarat
0
140
Amazon Bedrock AgentCore ワークショップ JAWS UG TOHOKU / amazon-bedrock-agentcore-workshop-jawsug-tohoku-2026
gawa
8
270
価格.comをAI駆動で全面刷新する ー 30年分の技術的負債を返し、次の30年の土台をつくる ー / AI Engineering Summit Tokyo 2026
tkyowa
49
52k
データ基盤をDataformで整えた話 〜 開発環境を添えて 〜
takapy
0
110
DevOps Agentで始めるAWS運用 〜フロンティアエージェントが変える運用の現場〜
nyankotaro
1
230
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
1.2k
AI Adaptable なテストを整える工夫 / Ways to Make Your Tests AI-Adaptable
bitkey
PRO
3
210
チームで実践する AI-DLC 思考の軌跡を残すチェックポイント設計
belongadmin
0
2.6k
サイバーセキュリティ概論 / Introduction to Cybersecurity
ks91
PRO
0
150
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.7k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
130
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
130
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
240
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
320
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
190
Abbi's Birthday
coloredviolet
2
7.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
190
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Transcript
Inside Bdash
@hokaccha
None
None
None
None
None
None
None
Flux Architecture of Bdash
Flux Frameworks
Topics • Domain Logicͷݺͼग़͠ • Storeͷׂ • ImmutableʹStateΛߋ৽͢Δ࣮
Domain Logicͷݺͼग़͠
Domain Logic • ඳըʹؔ͢Δ͜ͱҎ֎ͷશͯͷॲཧ • DatabaseͱͷΓऔΓͱ͔ • APIݺͼग़͠ͱ͔ • ઃఆͷཧͱ͔
Ͳ͜ʹ͋Δ͖͔ • Store? • Actino Creator? • Middleware?
None
import { dispatch } from './QueryStore'; import Database from '../lib/Database';
const QueryAction = {}; QueryAction.addNewQuery = params => { Database.Query.create(params).then(query => { dispatch('addNewQuery', { query }); }); }; Action Creator 㲗 Domain Logic
• Domain LogicΛFluxͷϑϩʔ͔Β͢Δ • Action Creator͔Βݺͼग़͚ͩ͢ • StoreStateͷߋ৽͚ͩʹྗ͢Δ
• StoreͱDomain Logicςετ͘͢͠ͳΔ • Action Creator͕ςετͮ͠Β͍ • શ͕ͯPure functionͱ͍͏ͷݬͳͷͰఘΊΔ
Storeͷׂ
ͭ·ΓStateΛͲ͏ׂ͢Δ͔
facebook/flux • Ϧιʔεʁ͝ͱʹStoreΛׂ͢Δ • DispatcherʹΑΔަ௨ཧɺwaitForΛͬͨ ґଘͷղܾ͕ඞཁ
Redux • StoreΛׂ͠ͳ͍ʢSingle Stateʣ • StateΛߋ৽͢ΔॲཧʢreducerʣΛׂ͢Δ • waitForDispatcher͕ෆཁ • State͕ڊେʹͳΔ
Bdash • Page୯ҐͰ͚ͯΈͨ • Page͝ͱʹಠཱͨ͠StoreΛ࣋ͭ • Page == Container Component
Query Page
DataSource Page
Setting Page
None
• Storeಉ࢜ͷґଘ͕ͳ͍ • waitForDispatcherෆཁ • StateΛΘ͔Γཻ͍͢ͰׂͰ͖Δ • શͯPage୯ҐͳͷͰΘ͔Γ͍͢ Good
• PageΛ·͍ͨͩσʔλͷڞ༗͕໘ • ෳͷPageͰಉ͡σʔλΛ࣋ͭ͜ͱ͋Δͷ Ͱແବ͕͋Δ Bad
PageؒͰͷσʔλڞ༗ • PageؒͰڞ༗͢ΔσʔλDomain LogicʹετΞ͢Δ • PageΓସ͑࣌ʹຖճDomain Logic͔ΒऔΓ͢
// Pageͷସ࣌ʹຖճݺΕΔAction Creator QueryAction.initialize = () => { Promise.all([ Database.fetchQueries(),
Database.fetchDataSources() ]).then(([queries, dataSources]) => { dispatch('initialize', { queries, dataSources }); }); }; // Store class QueryStore { reduce(type, { queries, dataSources }) { switch (type) { case 'initialize': { // ߋ৽͚ͩϚʔδ͢ΔͷͰସલͷঢ়ଶอ࣋Ͱ͖Δ return merge(this.state, { queries, dataSources }); } } } }
αʔόʔαΠυͷߟ͑ํ ͱಉͩ͡ɾɾʂ
൚༻తͳઃܭͰͳ͍ ⚠
ΞϓϦέʔγϣϯʹ దͨ͠ઃܭΛɻ
ImmutableͳStateͷߋ৽
let state = { todos: [ { id: 1, text:
'foo' }, { id: 2, text: 'foo' }, ], //... } function updateTodo(state, { id, text }) { return Object.assign({}, state, { todos: state.todos.map(todo => { if (todo.id === id) { return Object.assign({}, todo, { text }); } else { return todo; } }), }); }
• Immutable.jsΈ͍ͨͳ๛ͳػೳ͍Βͳ͍ • ωετͨ͠Stateͷߋ৽Λ؆୯ʹ͍͚ͨͩ͠ • ͍͔ͭ͘ϥΠϒϥϦ͋Δ͚ͲΈʹ߹Θͳ͍
࡞ͬͨ
import immup from 'immup'; let state = { todos: [
{ id: 1, text: 'foo' }, { id: 2, text: 'foo' }, ], //... } function updateTodo(state, { id, text }) { let index = state.todos.findIndex(todo => todo.id === id ); return immup.set(`todos.${index}.text`, text); }
StoreʹΈࠐΉ reduce(action, payload) { switch (action) { case 'addNewQuery': {
return this .set('selectedQueryId', payload.query.id) .set('editor.line', null) .prepend('queries', payload.query); } //... } }
·ͱΊ • Domain LogicAction Creator͔ΒݺͿΑ͏ ʹͯ͠Έͨ • StoreΛPage୯ҐͰׂͯ͠Έͨ • Stateߋ৽ͷͨΊͷศརϞδϡʔϧ࡞ͬͨ
None