I'm developing an application that has a grid of cells where the user can drag objects from 3 containers. The grid is comprised of row components, each of which has 5 cell components for storing the objects. Each cell component subscribes to 2 observables:
- One is sent when the user modifies the name of an object, so we have to look for all the instances of it in the grid and change its name.
- The other one is sent when the user wants to search for and highlight an object in the grid.
Also, each cell handles onDragEnter, onDragLeave and onDragDrop events to deal with the dragged objects. We're using OnPush strategy on all the rows and cells, and we call Angular's detectChanges()
only when they need to be updated.
We're doing some tests loading grids of 40-50 rows and we've realized that the app performance drops down quite noticeably. I'm pretty sure that the bottle neck comes from all these subscriptions and event handlers so I'm thinking how I could optimize the app.
I'm thinking of using only one subscription for both actions (change name and highlight objects) but I'd also like to know if there's a way to "deactivate" subscriptions when the components are not visible in the browser window and subscribe again when the user scrolls to them.
Has anyone had this scenario in an Angular app? Any ideas are welcome ;)
Thanks,