PVermeer / dexie-addon-suite-monorepo

MIT License
8 stars 0 forks source link

Dexie-RxJs-Addon: Making use of liveQuery #38

Open SIREtheKnight opened 11 months ago

SIREtheKnight commented 11 months ago

Hello dexie addon suite creators! Thanks a bunch for these addons.

I was running into a small performance problem related to Dexie-RxJs-Addon. The performance problem is with Dexie.Observable, which creates a couple of meta tables(_changes, _intercomm, _syncNodes, _uncommitedChanges) to persist and sychronize changes. They write about this issue in their documentation (the top section with bold https://dexie.org/docs/Observable/Dexie.Observable).

They have since then made the switch to use liveQuery() because the old way was doing much more than needed and also in order to optimize storage and performance. Could the dexie-rxjs-addon suite also not make use of liveQuery for the same reasons? From what I can tell, the liveQuery() returns a Dexie.Observable which does not allow typical rxjs operators like pipe'ing. But I believe we could wrap the liveQuery in an rxjs from() which should turn the dexie.observable into a rxjs observable.

I was just curious if you had any thoughts in this area and if you maybe see a potential upgrade aswell?

Appreciate the addon a bunch, have a nice day!

PVermeer commented 11 months ago

I've tested this and this should work fine but...

liveQuery Was introduced in dexie 3.2. This addon should work with all v3 versions.

Also this would introduce a breaking change because liveQuery does not provide change objects as currently exposed via changes$ on the tables.

So for now this is on hold and might get changed when dexie 4 releases so we can introduce some breaking changes. I will leave this open for when it releases.

SIREtheKnight commented 11 months ago

Yeha that makes sense. I just wanted to suggest it as dexie optimized it on their end, so it could make sense for the addon to follow. Thanks again for the work!