| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | import * as TKUnit from "../TKUnit"; | |
| 2 | - import { Page, NavigatedData } from "tns-core-modules/ui/page"; | ||
| 2 | + import { EventData, Page, NavigatedData } from "tns-core-modules/ui/page"; | ||
| 3 | 3 | import { topmost as topmostFrame, NavigationTransition } from "tns-core-modules/ui/frame"; | |
| 4 | 4 | import { Color } from "tns-core-modules/color"; | |
| 5 | 5 | import * as helper from "../ui/helper"; | |
@@ -377,4 +377,41 @@ export function test_NavigationEvents_WithClearHistory() { | |||
| 377 | 377 | ||
| 378 | 378 | export function test_NavigationEvents_WithClearHistory_WithTransition() { | |
| 379 | 379 | _test_NavigationEvents_WithClearHistory({ name: "fade", duration: 10 }); | |
| 380 | + } | ||
| 381 | + | ||
| 382 | + export function test_Navigate_From_Page_Loaded_Handler() { | ||
| 383 | + _test_Navigate_From_Page_Event_Handler(Page.loadedEvent); | ||
| 384 | + } | ||
| 385 | + | ||
| 386 | + export function test_Navigate_From_Page_NavigatedTo_Handler() { | ||
| 387 | + _test_Navigate_From_Page_Event_Handler(Page.navigatedToEvent); | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + function _test_Navigate_From_Page_Event_Handler(eventName: string) { | ||
| 391 | + let secondPageNavigatedTo = false; | ||
| 392 | + | ||
| 393 | + const firstPageFactory = function (): Page { | ||
| 394 | + const firstPage = new Page(); | ||
| 395 | + firstPage.id = "first-page"; | ||
| 396 | + firstPage.on(eventName, (args: EventData) => { | ||
| 397 | + const page = <Page>args.object; | ||
| 398 | + const frame = page.frame; | ||
| 399 | + | ||
| 400 | + const secondPageFactory = function (): Page { | ||
| 401 | + const secondPage = new Page(); | ||
| 402 | + secondPage.id = "second-page"; | ||
| 403 | + secondPage.on(Page.navigatedToEvent, () => { secondPageNavigatedTo = true }); | ||
| 404 | + | ||
| 405 | + return secondPage; | ||
| 406 | + }; | ||
| 407 | + | ||
| 408 | + frame.navigate(secondPageFactory); | ||
| 409 | + }); | ||
| 410 | + | ||
| 411 | + return firstPage; | ||
| 412 | + }; | ||
| 413 | + | ||
| 414 | + helper.navigateWithEntry({ create: firstPageFactory }); | ||
| 415 | + | ||
| 416 | + TKUnit.waitUntilReady(() => secondPageNavigatedTo); | ||
| 380 | 417 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -216,8 +216,13 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { | |||
| 216 | 216 | } | |
| 217 | 217 | ||
| 218 | 218 | this._currentEntry = entry; | |
| 219 | - this._executingEntry = null; | ||
| 219 | + | ||
| 220 | 220 | newPage.onNavigatedTo(isBack); | |
| 221 | + | ||
| 222 | + // Reset executing entry after NavigatedTo is raised; | ||
| 223 | + // we do not want to execute two navigations in parallel in case | ||
| 224 | + // additional navigation is triggered from the NavigatedTo handler. | ||
| 225 | + this._executingEntry = null; | ||
| 221 | 226 | } | |
| 222 | 227 | ||
| 223 | 228 | public _updateBackstack(entry: BackstackEntry, isBack: boolean): void { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments