110 add suspendmode support#111
Open
iObject wants to merge 8 commits into
Open
Conversation
- Run beforeViewSuspend before the view is hidden on the clearStackOnResolve path (previously the active keepAlive view was hidden before the hook fired, breaking the documented ordering) - Default unrecognized/missing suspendMode values to offscreen in hideView so a view is never left on-screen-but-hidden - Add RecordingView test component and ordering regression tests covering both the suspendView and clearStackOnResolve suspend paths
- closeView: drop the redundant up-front hide (it was immediately overwritten by the post-hook removal). The view now stays visible during _beforeViewClose — consistent with suspendView and the forward-nav close path — and is destroyed once the hook resolves. Add an isNode guard mirroring suspendView. - Sample/README: route the beforeViewSuspend fade resolution through a single idempotent resolveSuspendPromise() helper, called from the animation observer and on re-entry, so an interrupted fade can never leave the awaited promise dangling and stall navigation.
keepAliveViewTarget renders behind viewTarget, so a keepAlive view left visible (suspendMode "visible") bled through behind the active view. - Add moveViewToKeepAlive helper that always hides + parks the view off-screen before reparenting into keepAliveViewTarget, regardless of suspendMode. Use it from suspendView and the post-show closeViews loop. suspendMode now only governs in-place (viewTarget) suspension; showView restores visibility on resume. - Warn at addRoutes when keepAlive is combined with suspendMode "visible" (no effect), without coercing the stored value. - Add a regression test asserting a suspended keepAlive "visible" view is hidden and off-screen in keepAliveViewTarget. - Document the in-place vs background distinction in the README.
Contributor
|
Hey there! I just built a new temporary npm package based on 8558e78. You can download it here or install it by running the following command: npm install https://github.com/rokucommunity/sgRouter/releases/download/v0.0.0-packages/rokucommunity-sgrouter-0.1.3-110-add-suspendmode-support.20260620003119.tgz |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds view suspension customization and a new lifecycle hook to sgRouter so outgoing views can run work/animations before being hidden, and so routes can choose how a suspended view is hidden (offscreen/hidden/visible).
Changes:
- Add
suspendModeroute option (offscreendefault,hidden,visible) and implement it in Router hide/suspend behavior. - Add
beforeViewSuspend/_beforeViewSuspendlifecycle hook and wire router suspension to await it. - Extend test coverage (including a new
RecordingViewtest component) and update the sample Catalog screen to demonstrate a fade transition.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test-project/components/Screens/Catalog/CatalogScreen.xml | Wraps content in a container + adds a fade animation definition. |
| test-project/components/Screens/Catalog/CatalogScreen.bs | Drives fade-in on open/resume and fade-out in beforeViewSuspend (returns deferred promise). |
| test-project/components/Scene/MainScene/MainScene.bs | Sets suspendMode: "visible" for /shows route to support layered transitions. |
| src/source/router.spec.bs | Adds unit tests for suspendMode behavior and beforeViewSuspend ordering. |
| src/source/interfaces.bs | Documents new suspendMode route option in the public interface. |
| src/components/View.xml | Declares _beforeViewSuspend and beforeViewSuspend functions on base View. |
| src/components/View.bs | Implements default beforeViewSuspend and internal _beforeViewSuspend wrapper. |
| src/components/Router.bs | Adds suspendMode default/validation, suspendView lifecycle ordering, moveViewToKeepAlive, and new hideView semantics. |
| src/components/RecordingView.spec.xml | Adds a test-only View subclass with suspendTrace field. |
| src/components/RecordingView.spec.bs | Implements test-only hooks to record suspend ordering/visibility. |
| README.md | Documents suspendMode and beforeViewSuspend including ordering guarantees and example usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Hey there! I just built a new temporary npm package based on 409af2c. You can download it here or install it by running the following command: npm install https://github.com/rokucommunity/sgRouter/releases/download/v0.0.0-packages/rokucommunity-sgrouter-0.1.3-110-add-suspendmode-support.20260622184253.tgz |
Comment on lines
806
to
+810
| if m.__router_activeView <> Invalid then | ||
| if NOT isActiveInCloseViews AND rodash.getBoolean(m.__router_activeView.route.routeConfig.keepAlive, "enabled") then | ||
| promisesToResolve.push(suspendView(m.__router_activeView)) | ||
| if isActiveInCloseViews then | ||
| if NOT rodash.getBoolean(m.__router_activeView.route.routeConfig.keepAlive, "enabled") then | ||
| hideView(m.__router_activeView) | ||
| end if |
Comment on lines
879
to
882
| end function).catch(function(error as Dynamic) as Dynamic | ||
| return promises.reject(error) | ||
| end function).toPromise() | ||
| end function |
Comment on lines
+83
to
+86
| function beforeViewSuspend(params = {} as Object) as Dynamic | ||
| print "BEFORE VIEW SUSPEND", params | ||
|
|
||
| ' Resolve any prior pending suspend promise first so it can never dangle if a new |
Comment on lines
+97
to
+102
| sub onFadeAnimationStateChanged(event as Object) | ||
| if event.getData() = "stopped" then | ||
| print "VIEW SUSPEND ANIMATION COMPLETE, RESOLVING SUSPEND PROMISE" | ||
| resolveSuspendPromise() | ||
| end if | ||
| end sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.