🚦 Nested routing, page controller lifecycle, and more #7
MihaelIsaev
announced in
Announcements
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
FragmentRouter
We may not want to replace the entire content on the page for the next route, but only certain blocks.
This is where the new
FragmentRouter
comes in handy!Let's consider that we have tabs on the
/user
page. Each tab is a subroute, and we want to react to changes in the subroute using theFragmentRouter
without reloading use page even though url changes.Declare the top-level route in the
App
classAnd declare
FragmentRouter
in theUserPage
classIn the example above
FragmentRouter
handles/user/profile
and/user/friends
subroutes and renders it under theNavbar
, so page never reload the whole content but only specific fragments. There are also may be declared more than one fragment with the same or different subroutes and they all will just work together like a magic!Btw
FragmentRouter
is aDiv
and you may configure it by callingBreaking changes
ViewController
has been renamed intoPageController
, Xcode will propose to rename it automatically.PageController
PageController
now have lifecycle methods:willLoad
,didLoad
,willUnload
,didUnload
.Also you can declare same methods without overriding, e.g. when you declare little page without subclassing
New convenience methods
alert(message: String)
- direct JS alert methodchangePath(to: String)
- switching URL pathMore
Id
andClass
now can be initialized simply with string like thisTiny little change but may be very useful.
App.current.window.document.querySelectorAll("your_query")
now works!Tip
🚨Please don't forget to update
Webber CLI
tool to version1.6.1
or above!This discussion was created from the release 🚦 Nested routing, page controller lifecycle, and more.
Beta Was this translation helpful? Give feedback.
All reactions