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
Boot Campアプリの動きを追ってみよう!/ Follow BootCamp App
Search
haramura
July 30, 2022
Programming
540
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Boot Campアプリの動きを追ってみよう!/ Follow BootCamp App
2022年7月30日(土)に、フィヨルドブートキャンプで開催された「初めてのLT会 Vol.12」に登壇したときの発表資料です。
haramura
July 30, 2022
Other Decks in Programming
See All in Programming
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
250
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
440
残高管理から台帳サービスへの進化
artoy
1
200
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Performance Optimization With LLMs
xleitix
0
130
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
350
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
contenteditable と日本語入力に向き合う
colorful12
0
200
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
140
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.1k
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
Ethics towards AI in product and experience design
skipperchong
2
440
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
330
Docker and Python
trallard
47
4.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
Documentation Writing (for coders)
carmenintech
77
5.6k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Transcript
Boot CampΞϓϦͷಈ͖Λ ͬͯΈΑ͏ʂ Fjord Boot Camp ॳΊͯͷLTձ Vol.12 @SatoshiHaramuraɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ2022/7/30
ࣗݾհ ɹɹɹɹ@SatoshiHaramura ɹɹɹɹɹݱࡏͷϓϥΫςΟεɹɿνʔϜ։ൃ ɹɹɹɹɹ͖ͳ͜ͱɹɹɹɹɹɿαφ🧖 ɹɹɹɹɹϗοͱ͢ΔॠؒɹɹɹɿϋϜελʔͷ͙͠͞ 2
νʔϜ։ൃʹऔΓΉʹ͋ͨͬͯ ɹɹɹɹɹɹɹɹɹAs IsɹɹɹɹɹɹɹɹɹTo Be ɹɹɹɹɹɹɹɹɹɹݱࡏͷ࢟ɹɹɹˠɹɹɹ͋Δ͖࢟ ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹˢ ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹΪϟοϓɹɹɹɹɹ=ɹIssue
ɹɹɹɹɹɹɹɹɹɹɹɹɹɹ ɹΪϟοϓΛຒΊΔɹ=ɹPR ɹɹɹɹɹɹɹɹɹɹɹɹ·ͣɺݱࡏͷ࢟ ΛΖ͏ʂ 3
λʔήοτͱΰʔϧ •λʔήοτ ɹBoot CampΞϓϦͷ։ൃΛ࢝ΊΑ͏ͱ͢Δਓ •ΰʔϧ ʮΞϓϦͷಈ͖͕গ͠ཧղͰ͖ͨͧʂʯͱࢥ͑Δ͜ͱ ɹɹe.g.
ʮใʯΛҰཡͰදࣔ͢Δ 4 ά ϩ
1. HTMLΛऔಘ 5 HTTPϦΫΤετ URI ɿ/reports MethodɿGET class ReportsController <
ApplicationController def index; end end HTTPϨεϙϯε HTML ϧʔτใ controllers/reports_controller.rb views/reports/index.html.slim μογϡϘʔυ ใҰཡ Path Method Controller#Action /reports(:format) GET reports#index header.page-header .container .page-header__inner h2.page-header__title = title = render 'reports/new_report' .page-body .container.is-md .page-filter.form = form_with url: reports_path, local: true, method: 'get' .form-item.is-inline-md-up = label_tag :practice_id, 'ϓϥΫςΟεͰߜΓࠐΉ', … = select_tag :practice_id, … #js-reports divλάͷidଐੑʹଐੑ(js-reports)Λ༩͍ͯ͠Δ͚ͩ DOMߏஙޙɺҰॠԿදࣔ͞Εͳ͍
2. DOMߏஙޙɺVueΠϯελϯεΛϚϯτ 6 import Vue from 'vue' import Reports from
'reports.vue' document.addEventListener('DOMContentLoaded', () => { const selector = '#js-reports' const reports = document.querySelector(selector) if (reports) { const userId = reports.getAttribute('data-user-id') const limit = reports.getAttribute('data-limit') const companyId = reports.getAttribute('company-id') new Vue({ render: (h) => h(Reports, { props: { userId: userId, limit: limit, companyId: companyId } }) }).$mount(selector) } }) reports.js (RailsଆͷJSϑΝΠϧ) DOMͷߏஙޙ idͷଐੑ͕js-reportsΛ୳͢ VueΠϯελϯεΛੜ idͷଐੑ͕js-reportsʹରͯ͠ɺVueΠϯελϯεΛϚϯτ ใҰཡίϯϙʔωϯτ(ෳͷใΛଋͶͨͷ)
3. ஔ͖͑ΒΕΔVueΠϯελϯε 7 <template lang=“pug"> ɹ// fetchதɺLoadingListPlaceholderΛදࣔ ɹ// fetchྃޙɺPagerͱReportΛදࣔ </template>
<script> import LoadingListPlaceholder from ‘loading-list-placeholder.vue' import Pager from 'pager.vue' import Report from ‘report.vue' … export default { computed: { reportsAPI() { const params = this.newParams if (this.isUncheckedReportsPage) { return `/api/reports/unchecked.json?${params}` } else { return `/api/reports.json?${params}` } }, methods: { async getReports() { const response = await fetch(this.reportsAPI, { method: ‘GET’, credentials: ‘same-origin’, … }).catch((error) => console.warn(error)) const json = await response.json().catch((error) => console.warn(error)) this.reports = json.reports … } } </script> reports.vue (ใҰཡίϯϙʔωϯτ) loading-list-placeholder.vue (ϩʔυதΛදݱ͢Δίϯϙʔωϯτ) • fetchத pager.vue (ϖʔδϟʔίϯϙʔωϯτ) • fetchྃޙ report.vue (ใίϯϙʔωϯτ) /api/reports.json?page=1ʹରͯ͠ɺGETϝιου
4. JSONܗࣜͷσʔλΛऔಘ 8 HTTPϦΫΤετ URI ɿ/api/reports.json?page=1 MethodɿGET class API::ReportsController <
API::BaseController def index @company = Company.find(params[:company_id]) if params[:company_id] @reports = Report.list.page(params[:page]) … end end HTTPϨεϙϯε JSONܗࣜͷจࣈྻ ϧʔτใ controllers/api/reports_controller.rb views/api/reports/index.json.jbuilder ใҰཡ (fetchத) ใҰཡ (fetchྃޙ) Path Method Controller#Action /api/reports(:format) GET api/reports#index json.reports @reports do |report| json.partial! "api/reports/report", report: report json.partial! "api/reports/checks", checks: report.checks json.partial! "api/comments/user_icons", comments: report.comments json.user do json.partial! "api/users/user", user: report.user end end json.currentUserId current_user.id json.totalPages @reports.total_pages ϩʔυத ใҰཡ { “reports”: [ { “id”: 1234512168338, “title”: "ࠓؤுΓ·ͨ͠", … }, … ], … }
·ͱΊ • RailsϦΫΤετʹԠͯ͡ɺHTMLJSONܗࣜͷσʔλΛฦ͢ • DOMͷߏஙΛτϦΨʔʹɺطଘͷDOMͱVue.jsͷԾDOMΛஔ͖͑Δ • ԾDOMͷཁૉίϯϙʔωϯτԽ͞Ε͍ͯΔ • fetchϝιουͰɺίϯϙʔωϯτʹඞཁͳσʔλͷΈΛऔಘ 9