CyCraft Magnetar Versions Save

A framework-agnostic syncing solution that auto-connects any DB/API with your local data store and has optimistic-UI built in 🌟

[email protected]

2 years ago

see CHANGELOG

[email protected]

2 years ago

highly improved the way streams can be closed. MUCH easier to use syntax now!!

breaking changes

stream

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

v0.1.4

3 years ago

breaking changes

fetch

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

merge, assign, replace, deleteProp

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()`

delete

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

@magnetarjs/[email protected]

3 years ago

@magnetarjs/plugin-firestore: 0.1.0

breaking change:

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 })