-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of sharing collections or models between apps (=modules, issue #15) #16
Comments
This is a very interesting issue, you touched Joachim :) While I was giving my talk on SPA's I've been asked about that few time, so people are definitely interesting in that. My experience so far - do not use the shared state. Sharing the state, which is commonly done through global namespace as the same anti-pattern as global variables. If application need some kind of data, it have to fetch it from server during loading as pass it to main view. Consider application as boundary there all data lives, it does not exchange the data with other applications. Furthermore, if you switch from one application to another - all data is gone. Data could be shared only within application (even not between application and sub-application). And it's done easily, passing the models and collections to views, which are I would be really happy to hear for some use cases of where the sharing of data between applications are really useful. |
Is it possible share data between application and sub-application or it's imposible? |
@JuanSiles I would not say, it's possible. Technically you can do that, by putting some data to global namespace. What I'm saying is that I see that as wrong practice - each application is responsible for it's own data. |
I really need to share data between application because I am developing a SPA to reserve tennis paddle. I use one application for reserve and other application for the club bar, and I would like to share data between these application because if a player drinks something from the bar I would like to add this drink in the application to reserve. Sorry for my English, I know that it's not very good |
An example of sharing data between apps could be a user model, which needs to be accessible in each app once the user has logged in. Even if you try to avoid sharing models/collections between apps, you need a way to share data between multiple views within an app. I think we've the following options:
|
@joafeldmann sharing data between multiple views is not a problem. Since the model passed to Regarding the user - it can be the case. In my experiece, we store not user model but some part of it, required to access API. Typically that kind of API token. In this case I prefer to use |
Why not use something like this: 'var vent = _.extend({}, Backbone.Events)' And then: vent.trigger('someevent', somedata) vent.on('someevent', handlerFn, this) |
How can I listen to events from a collection created in a different "app"? Using a global namespace?
The text was updated successfully, but these errors were encountered: