bigwheel-framework / bigwheel

bigwheel is an unopinionated, minimalist frontend framework that manages application state
MIT License
73 stars 10 forks source link

Better sub route handling #3

Closed mikkoh closed 8 years ago

mikkoh commented 9 years ago

Currently one route is tied so heavily to one section it causes issues.

For instance:

{

    routes: {

        '/gallery': gallerySection,
        '/gallery/:item': galleryItem
    }
}

If you went to the route '/gallery/1' the gallerySection would never resolve.

A better way to do it might be to do the following:

{
    routes: {

        '/gallery': {

            section: gallerySection,

            routes: {

                '/gallery/:id': {

                    section: galleryItem
                }
            }
        }
    }
}

This would allow the framework to know that it needs to continue resolving routes potentially for a section.

mikkoh commented 9 years ago

It might be better to do it so sub sections can create their own sub frameworks. A gallery is a good example. It could look something like:

var galleryFrameWork = framework.sub( '/gallery' , function( done ) {

  done( {

    routes: {

      '/:galleryId': someSection // would match "#!/gallery/10"
    }
  });
});

It would also be good to think of passing the framework that caused the section to come in to be passed in the init function.

But also all frameworks should have ref to their parent:

galleryFrameWork.parent == framework // true