Closed LucaColonnello closed 9 years ago
Update: I have set this to the books State config:
var State = Abyssa.State,
Router = Abyssa.Router,
router;
router = Router({
index: State('/', function() { console.log( "enter index" ); }),
books: State('/books', {
enter: function() {
console.log( "enter books index" );
},
exit: function(){
console.log( "exit books index" );
},
index: State(''),
detail: State(':id', {
enter: function(params) {
console.log( "enter books detail", params );
},
exit: function(params){
console.log( "exit books detail", params );
}
})
})
})
.configure({
enableLogs: false,
urlSync: true
})
.init('index');
It Works!
It is not a great solution for code cleaning. If this could be solved differently, it will be great!
Hello LucaColonnello, you actually found the solution by yourself. Only leaf states can be transitionned to (it should be mentionned in the README). If all combinations were possible, there would be many conflicts and unresolvable paths especially when reverse-routing (router.link)
I hope it answers your question.
It will be possible to create the empty route Abyssa itself? Or if not, can make sense?
Maybe it's possible to create the default, empty route if there is no conflicting route for that parent already, yes. I need to think about it.
Ok, let me know, this pattern is the obviously better solution for HMVC application, preventing some interaction problem and limitation.
I saw that You have did this update on 7.0.0. Is just what I saw?
State( "url/url/url", { enter: ... , exit: ... }, { children: ..., children: ... } )
I'm not sure I'm following.
That change in 7.0.0 just brings a different way to declare a state and its hierarchy; it doesn't introduce some kind of default state for each level of a hierarchy like you wanted, if I understood correctly.
I think it's a good idea to implement this (although only future usage will confirm) so I'm going to work on it; A few other changes are needed to make this work though.
Yeah, I think! It would be great if You implements either guards and parameter's validation.
With guards you can apply policy and condition to allows route entering.
Il sabato 9 maggio 2015, AlexGalays notifications@github.com ha scritto:
I think it's a good idea to implement this (although only future usage will confirm) so I'm going to work on it; A few other changes are needed to make this work though.
— Reply to this email directly or view it on GitHub https://github.com/AlexGalays/abyssa-js/issues/31#issuecomment-100476633 .
Luca Colonnello 340 8707406 luca.colonnello91@gmail.com
Implemented in 7.0.1
Check this jsBin: http://jsbin.com/zomimotiyu/1/
Going on "/books" it doesn't match books state. I tried to use an internal state booksIndex url at "" and it works!
I have to make books State parent of bookDetail and it must enter when url is "/books", do some stuff and when I click for a book detail the url must be "/books/2" and it must not exit the books State.
How can I do this?