Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ElectronでFirebaseを使ってみた(仮)

 ElectronでFirebaseを使ってみた(仮)

ElectronでFirebaseを使ってみました。

Masaya Nasu

June 03, 2016
Tweet

More Decks by Masaya Nasu

Other Decks in Programming

Transcript

  1. ૊Έ߹Θͤͨಈػ • Electron΋1ܥʹͳֶͬͨ͠ͼ௚͢ࠒ߹͍ • EvernoteͷΑ͏ͳ΋ͷΛ࡞Γ͔ͨͬͨ • σʔλΛͲ͏ཷΊΔ͔ʹ೰Μͩ • nedb 


    https://github.com/louischatriot/nedb • electron-json-storage 
 https://github.com/jviotti/electron-json-storage • etc…etc… • Firebaseͷrealtime databaseΛ༻͍Ε͹͍͚ͦ͏
  2. Ϣʔβ࡞੒ 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; // ... });
  3. Ϣʔβೝূ 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); });
  4. 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()); });
  5. ·ͱΊ • ೝূ͸ଞͷαʔϏεͷOAuth࢖͑ͳ͍͚Ͳemail͔ͭͬͨೝূ͸ग़ དྷΔ • realtime database͸บ͕͋Δ • ϦΞϧλΠϜͰߋ৽͞ΕΔ͔Βຊ౰͸νϟοτ޲͚ͩΑͶ •

    ࣮͸ೝূͳ͠Ͱ࢖͑Δ • ܯࠂ͕ग़ଓ͚Δ͔Βݸਓ༻్Ͱ࢖͓͏ʂ • ࠷ऴతʹElectron͋Μ·Γؔ܎ͳ͘ͳͬͪΌͬͨ