Closed mark-at-pieces closed 3 years ago
Sorry for the late response. If I understood your question correctly, you get the changes from the hooks. https://github.com/dappsnation/akita-ng-fire/blob/v4.0.0/projects/akita-ng-fire/src/lib/collection/collection.service.ts#L57 So you could check when something is added and then check again when you get something from valueChanges etc.
protected onCreate?(entity: EntityType, options: WriteOptions): any;
protected onUpdate?(entity: Partial
Are really awesome but these unfortunately are just write hooks, I was looking more for something like a read hook so I could filter respectively. I can get these https://firebase.google.com/docs/firestore/query-data/listen#view_changes_between_snapshots changes only if I subscribe to syncCollection, or valueChanges.
assets
.syncCollection((reference) => reference.where(`users.${user}`, '==', true))
.subscribe(async (assets) => {
// console.log('stream assets!', assets);
for (const { type, payload } of assets as DocumentChangeAction<ServerAssetInterface>[]) {
const data = payload.doc.data();
const uid = payload.doc.id;
switch (type) {
case FIRESTORE_ACTION_ENUM.ADDED:
// do something
break;
case FIRESTORE_ACTION_ENUM.MODIFIED:
// do something
break;
case FIRESTORE_ACTION_ENUM.REMOVED:
// do something
break;
default:
throw new Error('Error Occurred unsupported Firestore action from assets Entity.');
}
}
});```
Guess then we need a new hook, something like onSnapshotChanges?
That would be extremely helpful. Thank you for your time!
Hey @MD-Widman , I had a talk with @GrandSchtroumpf , which is the founder of this library and the said that this is not really in the scope of a collection service. Since the collection service should only care about functionalities that are in the scope of a collection or document. In the PR that I referenced above you can see I just re exported the functionality from AngularFire which is kinda redundant. So I would suggest that you are using the AngularFire lib directly for your case, does it make sense for you?
@fritzschoff thank you for you time
Looking into a way to get these types of changes: View changes between snapshots within akita-ng-fire?
Any thoughts?
Also Akita-ng-fire makes my life 10x easier. Y'all are awesome!