K
K
kolofut2014-11-18 15:24:31
JavaScript
kolofut, 2014-11-18 15:24:31

Marionette.js, how to properly store a collection that is shared by multiple modules?

Point to the right path!
Maybe I don’t understand something, but speaking more specifically, we have, for example, a collection of users (it must always be up to date, that is, it is regularly synchronized with the server), in the user management module we create / edit etc .. . , respectively, there is another module in which we need to know everything about all users. Exactly what is the right way to do this?
The only option that I see is to store in one module, and another module will receive via request/response. But in this case, the question arises what to do if the module in which the collection is stored was stopped ...
PS: If the question is a little chaotic, clarify the details :) I'm still in the process of studying the puppet

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aen, 2014-11-18
@kolofut

If you need your collection to work and be always available, then there is no point in storing it in a module that has something else in it. It's a separate entity that you need to access through the event bus that Backbone.Wreqr gives you.
In your description "user module" is not the same as collection. As far as I understand, you have some piece of logic that is responsible for users and that works with the collection. Then in your case, you need to turn off only this piece of logic, and leave the collection alone. Then you will always have access to it.

S
Stanislav Romanov, 2014-11-18
@Kaer_Morchen

I didn’t use Marionette.js, but in ember.js it’s done like this - there is a store (store) that stores models in itself, loads the missing ones and gives them on request. The storage itself, through dependency injection, is available in all places where it is needed (in the route, in the controller, etc.). The storage is initialized during the application start and does not turn off in any way, it is an independent object. Quite an honorable decision.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question