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
ElectronでFirebaseを使ってみた(仮)
Search
Masaya Nasu
June 03, 2016
Programming
2
3.3k
ElectronでFirebaseを使ってみた(仮)
ElectronでFirebaseを使ってみました。
Masaya Nasu
June 03, 2016
Tweet
Share
More Decks by Masaya Nasu
See All by Masaya Nasu
What's new in Go 1.23
nasum
0
66
カミナシのフロントエンド開発の効率化の取り組み
nasum
2
260
新参者だけどバーンアウトしかけているチームを立て直す
nasum
21
11k
DjangoではじめるGraphQLとフロントエンド開発の協業
nasum
1
3.2k
Flutterとfirebaseを使ってモバイルアプリに挑戦してみる
nasum
3
2.8k
grpc-gatewayで作るマイクロサービスの管理画面
nasum
1
7.4k
コストをかけずに機械学習の環境を整える&学習環境(人間の)
nasum
0
1.5k
Elixirの好きなところ
nasum
0
470
Vue.jsを導入する際失敗したこと
nasum
1
4.1k
Other Decks in Programming
See All in Programming
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
590
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.1k
Tuning GraphQL on Rails
pyama86
2
1.2k
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
720
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
110
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
280
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
500
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
0
110
みんなでプロポーザルを書いてみた
yuriko1211
0
180
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
180
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
440
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
220
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Gamification - CAS2011
davidbonilla
80
5k
Fireside Chat
paigeccino
33
3k
Automating Front-end Workflow
addyosmani
1366
200k
Faster Mobile Websites
deanohume
305
30k
Rails Girls Zürich Keynote
gr2m
93
13k
Visualization
eitanlees
145
15k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Transcript
ElectronͰFirebaseΛͬͯ ΈΔʢԾʣ Gotanda.js #4 in Retty
ࣗݾհ • Github @nasum • twitter @tomato360
Electron • ݴΘͣͱΕͨGithubͷϑϨʔϜϫʔΫ • ࠷ۙ1.0͕ϦϦʔε͞Ε·ͨ͠ • ͏1.2.1ʹͳͬͯΔɻૣ͕͞ා͍ • ηΩϡϦςΟେมͳΠϝʔδ ElectronΞϓϦͷXSSͰrm
-fr /Λ࣮ߦ͢Δ http://qiita.com/akameco/items/cc6fc949e7c9f0d1a42a
Firebase • Google͕ങऩͨ͠BaaS • ϦΞϧλΠϜʹσʔλΛಉظ͢ΔͷʹڧΈͷ ͋ΔαʔϏε • Google IO Ͱϩάղੳϓογϡ௨ͷػೳ
͕Ճ͞Εͯ
Έ߹Θͤͨಈػ • Electron1ܥʹͳֶͬͨ͠ͼ͢ࠒ߹͍ • EvernoteͷΑ͏ͳͷΛ࡞Γ͔ͨͬͨ • σʔλΛͲ͏ཷΊΔ͔ʹΜͩ • nedb
https://github.com/louischatriot/nedb • electron-json-storage https://github.com/jviotti/electron-json-storage • etc…etc… • Firebaseͷrealtime databaseΛ༻͍Ε͍͚ͦ͏
FirebaseͷWeb൛ͰͰ͖Δ͜ͱ • Authentication • Realtime Database • Storage • Hosting
• Cloud Messaging ElectronͰ͑ͦ͏
ҙɿͣͬͱܯࠂ͕Ͱ·͢
ElectronͰAuth • ElectronͰGoogleTwitterɺFacebookͷೝূ͑ͳ͍ • origin͕file://͔ͩΒઃఆͰ͖ͳ͍ • CordovaͰࣅͨΑ͏ͳ͜ͱͰΜͰ͍Δਓ͕͍ͨ https://groups.google.com/forum/#!topic/firebase-talk/ eUzTjj8mVa4 •
signInWithEmailAndPasswordΛ͑ೝূग़དྷΔ https://firebase.google.com/docs/auth/web/password- auth#before_you_begin
Ϣʔβ࡞ var auth = firebase.auth(); auth.createUserWithEmailAndPassword(email, password).then(function(){ console.log('ok') var uid
= auth.currentUser.uid; console.log(uid) writeUserData(uid, "hoge", email); }).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; // ... });
Ϣʔβೝূ var auth = firebase.auth(); auth.signInWithEmailAndPassword(email, password).then(function(){ console.log('ok') var uid
= auth.currentUser.uid; console.log(uid) }).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; console.log(errorCode); console.log(errorMessage); });
ೝূ݁Ռ
ೝূใLocalStorageʹೖΔ
ೝূ͏·͍ͬͨͧ͘ʂ ʢͰݸਓ༻్ͰೝূΘͳ͍͔Ͷʂʣ
Realtime Database • ίϯιʔϧͰϧʔϧΛܾΊΔඞཁ͕͋Δ • ݁ߏෳࡶͰ׳ΕΔ·Ͱେม • FirebaseͷRulesΛཧղ͢Δ http://qiita.com/laco0416/items/ b068ab0cf19a26f0992d
ࢼ͠ʹ࡞ͬͨϧʔϧ
ϧʔϧςετͰ͖Δ
realtime databaseʹอଘ͢Δ ίʔυ var auth = firebase.auth(); var uid =
auth.currentUser.uid; var obj = { "title": "test", "description": "description" }; //σʔλΛηοτ͢Δ firebase.database().ref('documents/' + uid).push(obj); //σʔλͷҰཡΛऔಘ͢Δ firebase.database().ref('documents/' + uid).once('value').then(function(snapshot) { console.log(snapshot.val()); }); //σʔλͷมߋΛݕ͠දࣔ͢Δ firebase.database().ref('documents/' + uid).on('value', function(snapshot) { console.log(snapshot.val()); });
ಈ͔ͯ͠ΈΔ
realtime database͏·͘ ͍͖ͦ͏ʂ
Ͱ͜͜Ͱ࣌ؒΕ storageͱ͔ࢼ͔ͨͬͨ͠
·ͱΊ • ೝূଞͷαʔϏεͷOAuth͑ͳ͍͚Ͳemail͔ͭͬͨೝূग़ དྷΔ • realtime databaseบ͕͋Δ • ϦΞϧλΠϜͰߋ৽͞ΕΔ͔Βຊνϟοτ͚ͩΑͶ •
࣮ೝূͳ͠Ͱ͑Δ • ܯࠂ͕ग़ଓ͚Δ͔Βݸਓ༻్Ͱ͓͏ʂ • ࠷ऴతʹElectron͋Μ·Γؔͳ͘ͳͬͪΌͬͨ