Last active
October 10, 2020 05:32
-
-
Save mchampaneri/a6cf58e119c71e990d721a490765f52a to your computer and use it in GitHub Desktop.
Using OrderdMap from immutable.js with firebase javascript example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { OrderedMap } = require('immutable'); | |
var documentMap = OrderedMap() | |
const messageListner = () => { | |
let unsubscribe = database | |
.collection('documents') | |
.orderBy('created_at', 'asc') | |
.limitToLast(10) | |
.onSnapshot(async (snap) => { | |
for (let msg of snap.docs) { | |
documentMap = documentMap.set(msg.data().created_at, msg.data()) | |
} | |
}, (err) => { | |
unsubscribe(); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment