Breeze Memory Management - Pattern / Practice?

I have an old SL4 / ria app that I am looking to replace with a breeze. I have a question about memory usage and caching. My app downloads task lists (a normal user will have access to about 1000 of these tasks). In addition, there are quite a few types of search entities. I want to make sure they are cached on the client side but updated per session. When the user opens an assignment, it loads many more related objects (anywhere from 200 to 800 additional objects) that make up multiple matrix-style views for the assignments. User can view the list of jobs or view one job at a time.

I feel like I have to take care of memory management, especially not knowing how the browser can handle it. Initially, I felt like this should all be 1 EntityManager and I would disable events when a user transitions from work, but I think this could benefit multiple assignment managers for life. Or perhaps I should create a new dataservice and EntityManager every time the user navigates to a new hash '/ # /' scope, as the comments on clear () seem to indicate that this will be faster? If I did, I suppose I would use pub / sub to notify other change view modes for entities? This sounds complicated and prejudices some of the benefits of the breeze as context.

Any advice or thoughts on this would be greatly appreciated.

+3


source to share


1 answer


I think I understand the question. I think I would use a multi-manager approach:

  • Lookups Manager - contains one-time lookups.
  • JobView Manager - "read-only" list of jobs in support of JobView
  • JobEditor Manager - one per edit session.

The Lookups manager maintains a canonical copy of the referenced objects. You can fill it once with one call to the server (see docs for what). This Lookups manager will Breeze-export these referenced objects to other managers who will Breeze-import them as they are created. My guess is that despite being numerous and varied, the total memory area of ​​the referenced objects is pretty low ... low enough that you can afford to have more than one instance in multiple managers. There are more complex solutions if this is NOT the case. But let it be for now.

The JobView manager has the required reference objects to display. If you were only showing the Projection of the Job, it would not have the jobs in the cache. Instead, you can have an array and a keymap. Keep it simple and assume that it has all of the Jobs, but no related objects.

You never save changes with this manager! When editing or creating a job, your application always launches the Job Editor view from its own VM and JobEditor Manager. Again, you import the reference objects you want, and when you edit an existing job, you also import the job.



I would use this approach anyway ... not just because of memory issues. I like to isolate sandbox editing sessions. Cancels easily. Gives me a clean way of storing pending changes in the browser storage so that the user doesn't lose their work if the app / browser is down. Opens the door for editing multiple Workplaces at the same time, without worrying about interdependent entities with changes. This is a proven sample that we have used forever in SL apps and should be applied in JS apps as well.

When editing a job completes successfully, you must inform the local client world about it. There are many ways to do this. If the ONLY place to know is JobView, you can hard-code the return feed in the application. If you want to be smarter, you can have a central single service that triggers events, especially regarding Job savings. JobsView and every new JobEditor communicate with this service. And if you want to be hip, you use the built-in "Event Aggregator" (your pub / sub) for that purpose. I would probably use Durandal for this application and it has an event aggregator.

To be honest, it is not that hard to use and import / export entities among managers ... ahem ... breeze. This is a good comparison to refreshing the Jobs list every time you return to it (although you will need the Refresh button because other users can add / modify those Jobs). You retain many of the benefits of Breeze: Query, Validation, Change Tracking, Saving in Batch, Entity Navigation (these reference lists are "free" in Breeze).

As a clarification, I don't know that I will automatically destroy the JobEditor / viewmodel / manager when I return to the JobView. In my experience, people often return to the same Job that they just left behind. I could take a look so you can go back and forth quickly and quickly. But now I'm getting complex.

+8


source







All Articles