How to use the @firebase/app.apps function in @firebase/app

To help you get started, we’ve selected a few @firebase/app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pubpub / pubpub-editor / src / addons / Collaborative / collaborativePlugin.js View on Github external
state: {
				init: ()=>{},
				apply: this.apply
			},
		};
		this.props = {
			decorations: this.decorations
		};

		/* Check for firebaseConfig */
		if (!firebaseConfig) {
			throw new Error('Did not include a firebase config');
		}

		/* Connect to firebase app */
		const existingApp = firebase.apps.reduce((prev, curr)=> {
			if (curr.name === editorKey) { return curr; }
			return prev;
		}, undefined);
		this.firebaseApp = existingApp || firebase.initializeApp(firebaseConfig, editorKey);
		this.database = firebase.database(this.firebaseApp);
		this.firebaseRef = this.database.ref(editorKey);

		/* Set user status and watch for status changes */
		this.database.ref('.info/connected').on('value', (snapshot)=> {
			if (snapshot.val() === true) {
				this.onStatusChange('connected');
			} else {
				this.onStatusChange('disconnected');
			}
		});
	}
github augustskare / krypto.cash / source / javascript / views / Sync.js View on Github external
import {h, Component} from 'preact';
import firebase from '@firebase/app';
import '@firebase/database';
import firebaseConfig from '../../../firebase-config';

import Button from '../components/button';
import {Input} from '../components/inputs';
import store from '../utils/store';

if (firebase.apps.length < 1) {
  firebase.initializeApp(firebaseConfig);
}

class Sync extends Component {
  constructor() {
    super();

    this.database = firebase.database();

    this.handleNewConnection = this.handleNewConnection.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
    this.onIcecandidate = this.onIcecandidate.bind(this);
    this.onDatabaseChange = this.onDatabaseChange.bind(this);
    this.handleConnect = this.handleConnect.bind(this);
    this.handleSync = this.handleSync.bind(this);