Stone.js API
    Preparing search index...

    React Native adapter for Stone.js.

    The Integration dimension for a native mobile application: it captures the platform's causes (the launch URL, deep links, in-app navigation), turns each into an IncomingBrowserEvent, hands it to the kernel, and runs the effect the view layer deferred. The domain it serves is unchanged from the one behind an HTTP adapter, which is the point of the whole exercise.

    It is the exact native counterpart of BrowserAdapter, with a NavigationSource where the browser has window.

    import { ReactNative } from '@stone-js/react-native-adapter'

    @ReactNative()
    @StoneApp()
    class Application {}

    Hierarchy

    Index
    • Create an Adapter.

      Parameters

      • blueprint: IBlueprint

        The blueprint to create the adapter.

      Returns ReactNativeAdapter

    blueprint: IBlueprint
    hooks: AdapterHookType<ReactNativeAdapterContext, unknown>
    middleware: AdapterMixedPipeType<ReactNativeAdapterContext, unknown>[]
    resolvedErrorHandlers: Record<
        string,
        IAdapterErrorHandler<RawEventType, RawResponseType, ExecutionContextType>,
    >
    • Build the raw response.

      Parameters

      • context: ReactNativeAdapterContext

        The event context.

      • OptionaleventHandler: AdapterEventHandlerType<IncomingBrowserEvent, OutgoingBrowserResponse>

        The event handler to be run.

      Returns Promise<unknown>

      The raw response wrapper.

    • Process one navigation intent through the kernel.

      Parameters

      • eventHandler: AdapterEventHandlerType<IncomingBrowserEvent, OutgoingBrowserResponse>

        The resolved event handler.

      • rawEvent: NavigationIntent

        The navigation intent.

      • executionContext: NavigationSource

        The navigation source.

      Returns Promise<unknown>

      The platform response.

    • Execute the event handler lifecycle hooks.

      Parameters

      • hook: KernelHookName

        The hook to execute.

      • eventHandler: AdapterEventHandlerType<IncomingBrowserEvent, OutgoingBrowserResponse>

        The event handler to be run.

      Returns Promise<void>

    • Execute adapter lifecycle hooks.

      Parameters

      • name: AdapterHookName

        The hook's name.

      • Optionalcontext: ReactNativeAdapterContext

        The event context.

      • Optionalerror: any

        The error to handle.

      Returns Promise<void>

    • Handle error.

      Parameters

      Returns Promise<AdapterEventBuilderType<unknown>>

      The raw response.

    • Handle the event.

      Parameters

      • context: ReactNativeAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingBrowserEvent, OutgoingBrowserResponse>

        The event handler to be run.

      Returns Promise<IAdapterEventBuilder<RawResponseOptions, IRawResponseWrapper<unknown>>>

      The raw response wrapper.

    • Create pipeline options for the Adapter.

      Returns PipelineOptions<ReactNativeAdapterContext, AdapterEventBuilderType<unknown>>

      The pipeline options for transforming the event.

    • Get the error handler for the given error.

      Parameters

      • error: Error

        The error to get the handler for.

      Returns IAdapterErrorHandler<NavigationIntent, unknown, NavigationSource>

      The error handler.

      IntegrationError

    • Get the event handler for the adapter.

      Returns AdapterEventHandlerType<IncomingBrowserEvent, OutgoingBrowserResponse>

      The event handler for the adapter.

      If the event handler is missing.

    • Run the adapter.

      Order matters here. The event handler is initialized before any listener is live, so a deep link arriving during startup cannot reach a handler that has not run its onInit hooks. Then the platform is bound (which yields the launch URL), then listeners are attached, and only then is the launch intent dispatched: the application always resolves exactly one route on startup, the one it was opened with or the base path.

      Idempotent: running again tears down the previous listeners first, so a hot reload never leaves two adapters answering the same intent.

      Type Parameters

      • ExecutionResultType = undefined

      Returns Promise<ExecutionResultType>

    • Send the raw event through the destination.

      Parameters

      • context: ReactNativeAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingBrowserEvent, OutgoingBrowserResponse>

        The event handler to be run.

      Returns Promise<unknown>

      Platform-specific response.

      IntegrationError

    • Tear the adapter down: stop listening to the platform and to the application, then run the onStop hooks. Safe to call when never started.

      Returns Promise<void>

    • Validate the context and event handler.

      Parameters

      • context: ReactNativeAdapterContext

        The context to validate.

      • eventHandler: AdapterEventHandlerType<IncomingBrowserEvent, OutgoingBrowserResponse>

        The event handler to validate.

      Returns void

      IntegrationError

    • Create the adapter.

      Parameters

      • blueprint: IBlueprint

        The application blueprint.

      Returns ReactNativeAdapter

      A new adapter instance.