Skip to content

Callback / Promise support in args or return type in brownfield.navigation.ts spec file #348

@Doko-Demo-Doa

Description

@Doko-Demo-Doa

Describe the feature

At the moment, only serializable data types are supported (as parameters). For return types, only void is supported...

Motivation

... which means we can't have support for callbacks (e.g: Data roundtrips from RN -> Native -> RN).

For example. Sometimes we need the data back from native side to decide on something on JS side (showing something, activating something,...).

Example code:

export type DummyType = {
  testParams: string;
  testCallback: (arg: string) => void;
  testAsyncCallback: (arg: string) => Promise<number>;
};

export interface BrownfieldNavigationSpec {
  test(arg: DummyType): void;
  testReturnAsync(arg: number): Promise<string>;
}

For reference, the bare codegen does support Promise:

export interface Spec extends TurboModule {
  add(a: number, b: number): Promise<number>;
}

Related Issues

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions