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 OrderHow to turn off bell sounds in VSC: `Settings → Search: Audio Cues → Disabled`
ars longa, vita brevis
Bram