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
Run multiple instances of Marionette.Application within the same page #1229
Comments
I tried here, but the last instantiated app takes over: https://github.com/lededje/headless-app |
This is because currently appRoutes cannot be shared: |
@thejameskyle Very nice fiddles, I'm going to tinker with the approuter and to try to allow you to pass a location object. Is there anything else you can think of that I could slip up on? |
Not sure, I don't personally use multiple applications in a page, the only thing I can think of that may be a problem is the global wreqr channel overlapping. ping @jmeas |
In v1.x you'll be fine with the app-level instances of Wreqr systems...in v2 it won't be that easy. In general I don't think is a very robust way to test your app for a number of reasons. On my phone tho so I can't go into the detail. |
If you have time, I would appreciate more details about this. |
@lededje I also don't see the point in having multiple applications running in one window. The management of everything would become very overwhelming very quickly i feel. Can you elaborate on why you would want to spin up 20 instances of an app and trigger a different page for each instance? |
I see value in having multiple apps on a page at once. Currently a pattern that many people use is to achieve this, is to basically treat modules as little apps that can be stopped and started. This tells me that there is a demand for this functionality (the module way is basically just a clever hack/trick). Multiple apps that have limited knowledge and access to other apps makes a ton of sense when you take into account the direction that we have been working on over the past few months, decoupled composable pieces TLDR: 👍 multiple apps |
@samccone I totally agree with modules being the way to go as long as you have a way to communicate between them. You build a module ultimately because you want it to be reusable throughout your application not exclusively. |
I think if we go down this path we will soon find that there's very little difference between Applications and Modules... |
Figured I'd leave this here... I'm currently working on implementing a new kind of module for my app http://jsfiddle.net/tXE82/ (warning: non-functioning code) These are to act as completely separate applications, and can be started up all by themselves or inside another Module. Looks something like this: var FooModule = Module.extend({
el : '#foo', // can be assigned by parent module
template : '#foo-template',
regions : { },
behaviors : { },
routes : { }, // inherits from parent module routes `"foo" + ":id" => "foo/:id"`
[methods...]: function () {
var myView = new MyView({ el: this.myRegion });
this.listenTo(myView, 'doSomething', function () {
this.transitionTo('routeName');
});
}
}); I haven't worked everything out at this point, but this is what I'd like to eventually see in Marionette. |
👍 for multiple app instances (and being able to unit test the app instance and things that hang off the instance!!!!!!) and getting rid of the horrible mess i inflicted on everyone with the module system in marionette. sorry about that. |
Gasp! Its @derickbailey, I thought you were dead. Tell me, how is Tupac doing? |
We don't need two issues for this, I think; it's really one topic. Closing in favor of #1321. |
I've been trying to get more than one instance of my app running on the same page, and they all appear to be fighting, the last instantiated app takes use of the router.
I think it would make a great addition to be able to shim the object used for routing so you could have multiple instances of your app running in the same window.
Why? An example; you have an app with 20 different screens and you are tinkering with the css. Spawn 20 instances of the app, trigger a different page for each instance and edit the css using inspect element and see the effect of your changes on all 20 screens at once. A brilliant time saver.
The text was updated successfully, but these errors were encountered: