The Sharing Fiction Newsletter

Share this post
DEV LOG: Linking VSCode and Firebase
bram.substack.com

DEV LOG: Linking VSCode and Firebase

Ice Blocks

Bram Adams
Feb 8
Share this post
DEV LOG: Linking VSCode and Firebase
bram.substack.com
the html ice blocks will use: title, code block, companion terminal cmd (optional)

VSC Extension Storage

Managing a VSC extension with state is not a trivial decision. There are tradeoffs in speed, memory allocation, and AFAIK no way to store locally on disk outside of Memento.

Firebase-admin take cares of the heavy lifting of state. By using the service account set up in Firebase, “local data” can be emulated in the cloud. The trick is to load Firebase after the extension has been activated. The path to service account can be stored as a env variable in local VSC settings.

// extension.ts

import * as firebase from './firebase.js';

...

export function activate(context: vscode.ExtensionContext) {
  console.log(firebase.db) // db object
}

// firebase.js

var admin = require("firebase-admin");
const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestore');
var serviceAccount = require("./service-acct.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

export const db = getFirestore();

// service-acct.json

{
    "type": "service_account",
    "project_id": "my_proj_id",
    "private_key_id": "my_secret",
    ...
}

Other News

  • There is no definite statement on how long Viltrumites live, but the community consensus is on the order of 10,000 years

  • Don’t sleep on human inventiveness

    Unlike other species, humans have a unique capacity to learn and evolve their intellectual understanding; plus, they invent things that materially change their circumstances, producing advances in everything.

    Principles for Dealing With the Changing World Order

  • How to turn off bell sounds in VSC: `Settings → Search: Audio Cues → Disabled`

ars longa, vita brevis

Bram

Share this post
DEV LOG: Linking VSCode and Firebase
bram.substack.com
Comments

Create your profile

0 subscriptions will be displayed on your profile (edit)

Skip for now

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.

TopNewCommunity

No posts

Ready for more?

© 2022 Bram Adams
Privacy ∙ Terms ∙ Collection notice
Publish on Substack Get the app
Substack is the home for great writing