Skip to content

feat: add support for callback parameters and promise return types in navigation methods#412

Open
Doko-Demo-Doa wants to merge 2 commits into
callstack:mainfrom
Doko-Demo-Doa:feature/promise-return-and-callback-args-support
Open

feat: add support for callback parameters and promise return types in navigation methods#412
Doko-Demo-Doa wants to merge 2 commits into
callstack:mainfrom
Doko-Demo-Doa:feature/promise-return-and-callback-args-support

Conversation

@Doko-Demo-Doa

@Doko-Demo-Doa Doko-Demo-Doa commented Jul 3, 2026

Copy link
Copy Markdown

This is a follow-up PR to #348

Summary

Brownfield Navigation lib is mostly a mirror of Turbo Module codegen with less boilerplate. Previously, only simple methods with void return type are supported. This PR introduces Promise return type (with supported data types) and callback in arguments. Match closely with Turbo Module's Codegen Typings.

Motivation

Brownfield navigation specs already supported declaring Promise<T> return types (isAsync was parsed and threaded into the generators), but the Android/iOS async method generators never actually called into the delegate, they just returned a hardcoded rejection. Any consumer relying on an async navigation method today gets "not_implemented" at runtime no matter what. This PR closes that gap and, since callback-style delegate methods are a common pattern in native navigation glue (e.g. "call me back when the native screen is dismissed" or "try to do X, but if user is not authenticated, tell me the error code."), adds support for that as a sibling feature to Promises.

Test plan

  • yarn vitest run in packages/cli — existing parser/generators suites still pass (pre-existing isAsync/Promise<T> return-type path unaffected).
  • parser.test.ts: function-typed param → MethodParam.callback populated correctly (incl. nested param name/type/optionality); Promise<T> return type → isAsync/promiseReturnType; throws for a Promise<T> parameter; throws for a non-void callback return type.
  • generators.test.ts: Kotlin delegate/module and Swift/Obj-C output for a method with a callback parameter; Kotlin module and Obj-C implementation output for an async method — asserts the delegate is actually invoked with the forwarded args + promise/resolve/reject, and that the old not_implemented stub string is gone.
  • All 24 tests across both files pass locally.
  • Regenerate native files in apps/RNApp + apps/AndroidApp + apps/AppleApp via brownfield-navigation-codegen against a spec with a callback param and a Promise-returning method, and confirm the Android/iOS projects still build.
  • Implement a callback + a Promise-returning method in the Android/iOS demo delegates and confirm end-to-end from JS: the callback fires and the promise resolves/rejects (not just that the generated code compiles). This is TBD.

Small question: Should I prepare a PoC or video for demonstration?

@hurali97

hurali97 commented Jul 3, 2026

Copy link
Copy Markdown
Member

@Doko-Demo-Doa Thanks for this PR! Allow us some time to go through it and test 👍

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.

2 participants