WatermelonDB icon indicating copy to clipboard operation
WatermelonDB copied to clipboard

Is there a way to pause/stop withObservables()

Open Stophface opened this issue 2 years ago • 3 comments

Is there a way to pause/stop withObservable()? Why? When working with react-navigation, the screen does not get unmounted, which means the withObservable() keeps on running, even if the screen is not focussed anymore. Assuming there are five or six screens connected to a rather large table, this would result in performance issue because all the screens would continiously read from the database (if there are changes), eventhough the screen is not in focus.

Stophface avatar Dec 29 '22 15:12 Stophface

Use withObserve in child components of the screen. When blurring the screen replace those components with placeholders. Restore on focus.

Edit: as temp solution like i use

ChrisSimoniMBT avatar Jan 05 '23 16:01 ChrisSimoniMBT

@ChrisSimoniMBT thanks. That sounds like a reasonable workaround. Do you know if the withObservables() also run, when the app went to the background?

Stophface avatar Jan 06 '23 21:01 Stophface

is there any permanent solution for this?

rohankm avatar Feb 09 '24 23:02 rohankm