1.0.7 • Published 2 years ago

fialog-core v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

fialog-core

Fialog Core

NPM JavaScript Style Guide

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

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1-b

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago