Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/Link/Component"

Index

Type aliases

BadUrl

BadUrl: function

Can be used to handle when a link cannot be opened

example
Create a toast ```ts import { Link } from '@ef-carbon/react-native-dom'; import { Url } from '@ef-carbon/primitive'; Link.badUrl = function(url: Url, { message }: Error): void { createToast(`Failed to open '${url}': ${message}`); } ```

Type declaration

    • (url: Url, error: Error): void
    • Parameters

      • url: Url
      • error: Error

      Returns void

Handler

Handler: function

The link handler. Will be invoked if a link is pressed in the application that matches the regular expression. The matches in the regular expression will be passed to the handler

example
Simple Handler ```ts import { Url } from '@ef-carbon/primitive'; import { Link } from '@ef-carbon/react-native-dom'; function handler(url: Url, path: string) { console.log(url, path); } Link.handlers.set(/^ui:\/\/handler\/.*$/, handler) ```

Type declaration

    • (url: Url, ...matches: Array<string>): Promise<void>
    • Parameters

      • url: Url
      • Rest ...matches: Array<string>

      Returns Promise<void>

Handlers

Handlers: Map<RegExp, Handler>

OpenUrl

OpenUrl: function

Can be used to customise the handling of links

example
Expo ```ts import { WebBrowser: { openBrowserAsync } } from 'expo'; import { Link } from '@ef-carbon/react-native-dom'; import { Url } from '@ef-carbon/primitive'; Link.openUrl = async function(url: Url): Promise { if (url.protocol.startsWith('http')) { await this.openBrowserAsync(`${url}`); return true; // Handled } return false; // Not handled, do default routine } ```

Type declaration

    • (url: Url): Promise<boolean>
    • Parameters

      • url: Url

      Returns Promise<boolean>

Variables

Const component

component: IStatic = Link

Functions

applyStyles

  • applyStyles(node: INodeMutable, theme: ITheme): void

defaultBadUrl

  • defaultBadUrl(url: Url, __namedParameters: object): void

defaultOpenUrl

  • defaultOpenUrl(_: Url): Promise<boolean>

handlers

linkBadUrl

  • linkBadUrl(url: UrlAccepted, error: Error): void

linkOpenUrl

  • linkOpenUrl(url: UrlAccepted): Promise<void>