Provide a way to compose apps together
See original GitHub issuelets think about something that takes a donejs-app or component and returns a app if XXX
and a component when YYY
also add something to read routes of apps if they are apps and combine them to a single viewModel
use case
Sometimes you want to code a donejs-app a small one that you can run test all indipendent like a donejs app but then use that app directly as a component in a bigger app.
Solutions:
- code a wrapper
- code some build process (that would loose route information i think)
example:
- coding a user manager as a app
- coding some other app that uses the users but displays total diffrent stuff + the user manager
my current solution
- donejs add app
- create routes on component usage add appName route(‘<appName>/{page}’, { page: ‘artist-list’});
- on component use remove or ignore can-route
- use a extra route.js inside your app that holds only the route viewModel
- merge stache bodys some how and stach headers or assign extra route for the app/component main
other solution
- create a extra bundle as component and as app.
findings:
Gregg Roemhildt @roemhildtg 14:10
@frank-dspeed I was looking into loading components
from different apps
in separate project folders, and it sort of works, but I ran into an issue where It was in a file project 1
, trying to load project2/file/file
and imports in that file had import stuff from '~/other/other
which steal interpreted as being in project1
even though the file is in proejct2
Solution
I had set up steal's paths to use this: "project2/*": "/apps/project2/*.js"
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:16 (11 by maintainers)
Top GitHub Comments
I kind of have a working sample of this I can share shortly. But what do you all think of using partials to render child apps?
For instance, my parent app has a progressively loaded “page” object that contains a renderer function. And my parent app template would render that page with something like this:
pagePromise
is a getter tied to can-route, so if the page changes, the pagePromise gets resolved again and setspageData
with the new renderer. pageData would look like this:Routes can be set up in a centralized config that might look something like this:
This seems to be pretty flexible and also pretty performant at first glance. I’ll share a demo once I get some things ironed out.
Thanks for the follow up. I understand much better now.
Why does developing them as separate apps mean you can’t use NPM?
If I were doing this sort of thing w/ just canjs, combining
cereals-app
andgrains-app
, I would do something like the following:cereals app
where
cereals-app.js
is a component like:and
index.js
basically boostraps everything:grains app would look the same.
Then I’d create a
cereals-and-grains
app that would combine them like:While this doesn’t scale upward great, I think it should handle things pretty well. To scale better, we’d need a folder-based routing system that also is able to render one app or another.