fialog-core
Fialog Core
Install
yarn add fialog-core
or
npm install --save fialog-core
Usage
<DataProvider schemas={{
api: {
provider: 'api',
},
api2: {
provider: 'api',
default: {
url: 'https://rest2.example.com'
}
},
firebase: {
provider: 'firebase',
firestore: getFirestore(),
firebaseConfig
default: {
collection: 'example' // Optional
}
},
firebase2: {
provider: 'firebase',
firebaseConfig: {
"apiKey": "...",
"authDomain": "...",
"projectId": "...",
"storageBucket": "..",
"messagingSenderId": "...",
"appId": "...",
"measurementId": "..."
},
default: {
collection: 'example' // Optional
}
}
}}>
useData
import { useData } from 'fialog-core'
let [data, loading, error] = useData(...dataSource)
APIDataWrapper
import { APIDataWrapper } from 'fialog-core'
...
<APIDataWrapper url='https://rest.example.com/singledata'>
<Data property='jsonpath' />
</APIDataWrapper>
ContentRenderer
import { ContentRenderer } from 'fialog-core'
...
<ContentRenderer content={`<APIDataWrapper url="https://rest.example.com/singledata" ><Data property="jsonpath" /></APIDataWrapper>`} />
ContentRenderer with Custom components
import { ContentRenderer } from 'fialog-core'
...
<ContentRenderer
content={`<APIDataWrapper url="https://rest.example.com/singledata" ><Data property="jsonpath" /></APIDataWrapper><UserData />`}
components={{ UserData }}
/>
useData
import { useData } from 'fialog-core'
// Single with ID
let [data, loading, error] = useData([ 'firebase', { id: `8BtHQ2cZAUnqHkgJDJBq` }]} ])
// Single with docPath
let [data, loading, error] = useData([ 'firebase', { docPath: `earn_receipts/8BtHQ2cZAUnqHkgJDJBq` }]} ])
// Multiple query
const options = {
collection: 'earn_receipts',
limit: 10,
query: [
['owner', '==', doc(getFirestore(), 'users/line:Uf03bd649d29d8dcbfe69743f316432a2')]
]
}
let [data, loading, error] = useData([ 'firebase', options])
License
© mekku