common-messanger
v1.7.3
Published
common messanger modules
Downloads
103
Readme
common-messanger
Install App
$ yarn add common-messanger
import * as firebase from 'firebase/app'
import { installApp } from 'common-messanger'
import 'firebase/auth'
import 'firebase/firestore'
const app = firebase.initializeApp({
"apiKey": apiKey,
"authDomain": authDomain,
"databaseURL": databaseURL,
"projectId": projectId,
"storageBucket": storageBucket,
"messagingSenderId": messagingSenderId,
"appId": appId
})
const firestore = firebase.firestore(app)
installApp(firestore)
Test
$ yarn test
Don't forget call dispose
import {
MessageObserver,
} from 'common-messanger'
// initialized
const messageObserver = new MessageObserver()
// just call once
messageObserver.messages$
.pipe(map((data) => data.messages))
.subscribe((messages) => this.setState({ messages }))
// when you want to fetch all messages
messageObserver.fetchMessage(roomId)
// when component will unmount
messageObserver.dispose()