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
Vue.js + TypeScript + Firebase
Search
nunulk
January 19, 2019
Technology
0
870
Vue.js + TypeScript + Firebase
nunulk
January 19, 2019
Tweet
Share
More Decks by nunulk
See All by nunulk
Laravelでテストしやすいコードを書く5 / 5 tips of building testable modules in Laravel
nunulk
0
240
Design It! in a nutshell
nunulk
1
190
PHP Getting Faster
nunulk
0
190
How does learning English broaden your world?
nunulk
0
280
Testing on Laravel
nunulk
1
1.3k
Nuxt.js in TypeScript
nunulk
1
340
A startup meets Laravel + Vue.js
nunulk
1
1.8k
Unit Testing Laravel
nunulk
0
400
A Third-rate Programmer Talked about a Survival Strategy for Software Engineers
nunulk
3
540
Other Decks in Technology
See All in Technology
contenteditableと向き合う
kikuchikakeru
2
140
waitany と waitall を作った話
mrkn
0
110
株式会社M2X エンジニアチーム紹介資料
m2xsoftware
0
320
Envoy External AuthZとgRPC Extensionを利用した「頑張らない」Microservices認証認可基盤
andoshin11
0
140
ことばをそろえる / Bridging the Terminology Gap
amaotone
5
1k
疎通2024
sadnessojisan
4
480
Chunk computing
matyo91
0
270
ログラスが面白いと思う理由をマネージャーがエモく語ってみる / 20240829 vs LT
yoshikiiida
1
520
LLM を現場で評価する
asei
4
670
技術ブログや登壇資料を秒で作るコツ伝授します
minorun365
PRO
16
4.4k
RAGHack: Kickoff and RAG 101
pamelafox
0
200
分野に潜むツールの紹介
pojiro
1
330
Featured
See All Featured
Clear Off the Table
cherdarchuk
90
320k
How GitHub Uses GitHub to Build GitHub
holman
472
290k
KATA
mclloyd
27
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
29
2.5k
Embracing the Ebb and Flow
colly
83
4.4k
What's in a price? How to price your products and services
michaelherold
241
11k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
248
20k
Teambox: Starting and Learning
jrom
131
8.7k
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
In The Pink: A Labor of Love
frogandcode
139
22k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
354
29k
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
Transcript
Vue.js + Firebase + TypeScript Ͱ ϦΞϧλΠϜνϟοτ nunulk #ReBuildCamp
Firebase • Google ͕ఏڙ͢Δ mBaaS • Cloud Firestore (Beta), Cloud
Storage, Cloud Functions, A/B Testing, Cloud Messaging
ٕͬͨज़ • Vue.js: 2.5.22 • TypeScript: 3.2.4 • Firebase: 0.3.7
• Element: 2.4.11
ೝূ͕ඞཁͳύεͷࢦఆ routes: [ { path: '/', name: 'home', component: Home,
meta: { requiresAuth: true } },
ϛυϧΣΞ router.beforeEach((to, from, next) => { const requiresAuth = to.matched.some(record
=> record.meta.requiresAuth) if (!requiresAuth) { next() } else { firebase.auth().onAuthStateChanged(function (user) { if (user) { next() } else { next({ path: '/signin', query: { redirect: to.fullPath } })
Component export default class ChatBoard extends Vue { user: User
= { id: null, email: '', avatar_image_url: '' } participants: User[] = [] messages: Message[] = [] message: Message = { room_id, sender_id: null, content: ‘', created_at: null, }
Component created(): void { const fireUser = firebase.auth().currentUser; if (!fireUser)
{ return; } this.user.id = fireUser.uid; this.user.email = fireUser.email; db.collection('users').doc(this.user.id).get() .then((doc) => {})
Component db.collection('messages') .onSnapshot((snapshot) => { const changes = snapshot.docChanges() if
(!changes) { return } changes.forEach((change) => { if (change.type === 'added') { const message = { room_id: change.doc.data().room_id, sender_id: change.doc.data().sender_id, content: change.doc.data().content, created_at: this.timestamp2String(change.doc.data().created_at) }; this.addMessageData(message); }
σϞ