collections: check if collection has clear fn

This commit is contained in:
thecodrr
2020-04-16 03:30:16 +05:00
parent 55b6b0733b
commit 14b72ee2f4
2 changed files with 4 additions and 4 deletions

View File

@@ -7,8 +7,8 @@ class Collection {
await collection._collection.init();
if (collection.init) await collection.init();
if (collection.clear)
this._db.ev.subscribe("clear", collection._collection.clear);
if (collection._collection.clear)
this._db.ev.subscribe("clear", () => collection._collection.clear());
return collection;
}

View File

@@ -14,9 +14,9 @@ export default class CachedCollection {
if (data.length > 0) this.map = new Map(data);
}
clear = () => {
clear() {
this.map.clear();
};
}
/**
*