This small Firestore app tests how onSnapshot() notifications fire when documents are updated in a transaction.
See https://groups.google.com/g/google-cloud-firestore-discuss/c/tORo0hykByc/m/RuYaMoCmBQAJ
- Run
npm install
to install dependencies. - Edit
firebase_config.ts
to fill out yourapiKey
andprojectId
(not required if you only want to use the Firestore emulator). - See the test code in
run_the_test.ts
.
- Run
npm run build
to generate the compiled JavaScript. - Open
index.html
in a web browser, and click the "Run Test" button.
- Run
npm run run
to run the code in Node on the command line.
To connect to the Firestore emulator, specify -e
.
To enable Firestore debug logging, specify -v
.
Example:
npm run run -- -e -v
The log lines like
[snapshot listener] GOT size=NNN ...
are printed every time that the snapshot listener is notified. I was wondering if it gets intermediate invocations as the transaction is partially committed; however, it only gets notified once before the transaction starts then once with the completed transaction.