@@ -146,49 +146,58 @@ const routeConfig = {
146146 id: 'app',
147147 tagName: 'APP-MAIN',
148148 path: '',
149+ beforeEnter: (currentNode, nextNodeIfExists, routeId, context) => {
150+ await setupServices();
151+ }
152+ routeEnter: (currentNode, nextNodeIfExists, routeId, context) => {
153+ doSomething();
154+ }
155+ routeExit: (currentNode, nextNode, routeId, context) => {
156+ teardownServices();
157+ }
149158 subRoutes: [{
150159 id: 'app-user',
151160 tagName: 'APP-USER-PAGE',
152161 path: '/users/:userId([0-9]{1,6})',
153162 params: ['userId'],
154- beforeEnter: () => {
163+ beforeEnter: (currentNode, nextNodeIfExists, routeId, context ) => {
155164 isAuthorized();
156165 import('../app-user-page.js')
157166 }
158- routeEnter: () => {
167+ routeEnter: (currentNode, nextNodeIfExists, routeId, context ) => {
159168 doSomething();
160169 }
161- routeExit: () => {
170+ routeExit: (currentNode, nextNode, routeId, context ) => {
162171 saveDataToCache();
163172 }
164173 }, {
165174 id: 'app-user-account',
166175 tagName: 'APP-ACCOUNT-PAGE',
167176 path: '/users/:userId([0-9]{1,6})/accounts/:accountId([0-9]{1,6})',
168177 params: ['userId', 'accountId'],
169- beforeEnter: () => {
178+ beforeEnter: (currentNode, nextNodeIfExists, routeId, context ) => {
170179 isAuthorized();
171180 import('../app-account-page.js')
172181 }
173- routeEnter: () => {
182+ routeEnter: (currentNode, nextNodeIfExists, routeId, context ) => {
174183 doSomething();
175184 }
176- routeExit: () => {
185+ routeExit: (currentNode, nextNode, routeId, context ) => {
177186 saveDataToCache();
178187 }
179188 }, {
180189 id: 'app-about',
181190 tagName: 'APP-ABOUT',
182191 path: '/about',
183192 authenticated: false,
184- beforeEnter: () => {
193+ beforeEnter: (currentNode, nextNodeIfExists, routeId, context ) => {
185194 isAuthorized();
186195 import('../app-about.js);
187196 }
188- routeEnter: () => {
197+ routeEnter: (currentNode, nextNodeIfExists, routeId, context ) => {
189198 doSomething();
190199 }
191- routeExit: () => {
200+ routeExit: (currentNode, nextNode, routeId, context ) => {
192201 saveDataToCache();
193202 }
194203 }]
0 commit comments