A framework-agnostic syncing solution that auto-connects any DB/API with your local data store and has optimistic-UI built in 🌟
see CHANGELOG
highly improved the way streams can be closed. MUCH easier to use syntax now!!
Before:
magnetar.collection('my-collection').stream()
// close stream:
const closeStream = magnetar.collection('my-collection').openStreams.get(undefined)
closeStream()
After:
magnetar.collection('my-collection').stream()
// close stream:
magnetar.collection('my-collection').closeStream()
See the new docs at: https://magnetar.cycraft.co/docs#stream-realtime-updates
fetch()
now returns the fetched data immediately:
Before:
const myModule = await magnetar.collection('my-collection').doc('my-doc').fetch()
const data = myModule.data
After:
const data = await magnetar.collection('my-collection').doc('my-doc').fetch()
// or
const myModule = magnetar.collection('my-collection').doc('my-doc')
await myModule.fetch()
const data = myModule.data
Before:
const myModule = await magnetar.collection('my-collection').doc('my-doc').merge({ key: 'value' })
myModule // the same `doc('my-doc')` ref
After:
const newData = await magnetar.collection('my-collection').doc('my-doc').merge({ key: 'value' })
newData // the modified data after `merge()`
Before:
const myModule = await magnetar.collection('my-collection').doc('my-doc').delete()
myModule // the same `doc('my-doc')` ref
After:
const result = await magnetar.collection('my-collection').doc('my-doc').merge({ key: 'value' })
result // undefined
You need to pass Firebase instance now, as opposed to the Firestore instance.
Eg.
// ---------------------------------------------
// 0. Make sure firebase is instantialized BEFORE magnetar
// ---------------------------------------------
import firebase from 'firebase/app'
import 'firebase/firestore'
firebase.initializeApp({
// ...
})
// ---------------------------------------------
// 1. the plugin firestore for remote data store
// ---------------------------------------------
import { CreatePlugin as PluginFirestore } from '@magnetarjs/plugin-firestore'
import firebase from 'firebase/app'
// create the remote store plugin instance:
const remote = PluginFirestore({ firebase })