Skip to content

Add beforeTransition hook to Flow and parity test [iOS]#803

Draft
bsatyani wants to merge 5 commits intomainfrom
PLAYA-10138
Draft

Add beforeTransition hook to Flow and parity test [iOS]#803
bsatyani wants to merge 5 commits intomainfrom
PLAYA-10138

Conversation

@bsatyani
Copy link

@bsatyani bsatyani commented Feb 18, 2026

This PR adds the beforeTransition flow hook on iOS so apps can observe or modify the navigation state before a transition, in line with the existing behaviour on JVM and in the TypeScript core.

The core player exposes a beforeTransition SyncWaterfallHook (state + transition name → state). JVM already exposes it on FlowInstance.Hooks; iOS FlowHooks only had transition and afterTransition. This change adds beforeTransition on iOS and a test that mirrors the JVM integration test.

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major
  • N/A

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs
📦 Published PR as canary version: 0.15.1--canary.803.31915

Try this version out locally by upgrading relevant packages to 0.15.1--canary.803.31915

Expose the flow's beforeTransition hook on iOS so callers can observe or
modify the navigation state before a transition, matching JVM behaviour.
@bsatyani bsatyani requested a review from spentacular February 18, 2026 19:38
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.85%. Comparing base (efd5962) to head (d21f563).

Files with missing lines Patch % Lines
ios/core/Tests/FlowStateTests.swift 96.96% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #803      +/-   ##
==========================================
+ Coverage   85.82%   85.85%   +0.03%     
==========================================
  Files         505      505              
  Lines       22823    22868      +45     
  Branches     2657     2657              
==========================================
+ Hits        19587    19633      +46     
+ Misses       2908     2907       -1     
  Partials      328      328              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bsatyani
Copy link
Author

/canary

intuit-svc added a commit to player-ui/player-ui.github.io that referenced this pull request Feb 18, 2026
@intuit-svc
Copy link
Contributor

intuit-svc commented Feb 18, 2026

Build Preview

Your PR was deployed by CircleCI #31915 on Mon, 23 Feb 2026 18:13:30 GMT with this version:

0.15.1--canary.803.31915

📖 Docs (View site)

@bsatyani
Copy link
Author

/canary

intuit-svc added a commit to player-ui/player-ui.github.io that referenced this pull request Feb 23, 2026
Copy link
Contributor

@KVSRoyal KVSRoyal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise lgtm.

Comment on lines +13 to +15
/// The backing JSValue. Use when returning this state from a waterfall hook (e.g. beforeTransition).
public var jsValue: JSValue { rawValue }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be public?

Comment on lines +126 to +131
let tapMethod: @convention(block) (JSValue?, JSValue?) -> JSValue? = { value, value2 in
guard let val = value, let val2 = value2 else { return nil }
let transitionValue = val2.toString() ?? ""
let typedState = NavigationBaseState.createInstance(value: val)
return hook(typedState, transitionValue)?.jsValue ?? val
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we do guard let value and keep the original names instead of shadowing the names? I think that's a little cleaner. Also, can we do value1 and value2 to keep the names consistent? E.g.

let tapMethod: @convention(block) (JSValue?, JSValue?) -> JSValue? = { value1, value2 in
    guard let value1, let value2 else { return nil }
    let transitionValue = value2.toString() ?? ""
    let typedState = NavigationBaseState.createInstance(value: value1)
    return hook(typedState, transitionValue)?.jsValue ?? value1
}

- parameters:
- hook: A function (state, transitionValue) -> state (or nil to pass through)
*/
public func tap(_ hook: @escaping (NavigationBaseState?, String) -> NavigationBaseState?) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this generic so it’s reusable and aligned with web’s SyncWaterfallHook?
have you tried using SyncWaterfallHook2JS<T, R, U> from this PR where T = first arg (e.g. state), U = second arg (e.g. transition name or options), R = return type (typically same as T for waterfall)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants