This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.sync( | |
'docData', // Document Dataと同期させたいpiniaのプロパティ名 | |
docRef // Document Reference | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PiniaFirestoreSync } from 'pinia-plugin-firestore-sync' | |
// Add plugin | |
const pinia = createPinia().use(firestoreSyncPlugin) | |
app.use(pinia).mount('#app' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install pinia-plugin-firestore-sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async setup() { | |
// Yay🙌 | |
this.sync('docDataA', docRefA) | |
this.sync('docDataB', docRefB) | |
this.sync('docDataC', docRefC) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async setup() { | |
// It's very vervose... | |
onSnapshot(docRefA, (ds) => { | |
if (ds.exists()) { | |
this.$patch({ docDataA: ds.data() }) | |
} | |
}) | |
onSnapshot(docRefB, (ds) => { | |
if (ds.exists()) { | |
this.$patch({ docDataB: ds.data() }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const useExampleStore = defineStore('expamle', { | |
state: {/*...*/} | |
actions: { | |
async setup() { | |
// ... | |
//🌟 Sync Pinia's state and Firestore document | |
onSnapshot(docRef, (ds) => { | |
if (ds.exists()) { | |
this.$patch({ docData: ds.data() }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const useExampleStore = defineStore('expamle', { | |
state: {/*...*/} | |
actions: { | |
async setup() { | |
// ... | |
//🌟 docDataとdocRefを同期 | |
onSnapshot(docRef, (ds) => { | |
if (ds.exists()) { | |
this.$patch({ docData: ds.data() }) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assignMokuji = function(){ | |
/** | |
* 指定したテキストでH1もしくはH2要素を見つける | |
* @param {*} text | |
* @returns | |
*/ | |
var findH1OrH2ByText = function(text) { | |
var h1 = $("h1:contains(" + text + ")").first() | |
if(h1[0]){ | |
return h1[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="container"> | |
<!-- ページをクリッピングするコンテナ --> | |
<div class="clipping-container"> | |
<!-- ページ全体、このleftをtransitionでスライドさせてページを動かす --> | |
<div class="pages" :style="{left: currentLeft}"> | |
<div class="page"> | |
1 | |
</div> | |
<div class="page"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct CounterView: View { | |
// Data binding with CounterView Model | |
@EnvironmentObject var counterViewModel: CounterViewModel | |
var body: some View { | |
return VStack { | |
// count value updated automatically by data binding | |
Text(String(self.counterViewModel.count)) |