docs: improve jsdoc for linking

This commit is contained in:
Satyajit Sahoo
2020-10-24 23:51:59 +02:00
parent bfd0d94985
commit 6cf124a190
3 changed files with 32 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ const getActiveRoute = (state: State): { name: string; params?: object } => {
/**
* Utility to serialize a navigation state object to a path string.
*
* Example:
* @example
* ```js
* getPathFromState(
* {

View File

@@ -37,7 +37,7 @@ type ResultState = PartialState<NavigationState> & {
* Utility to parse a path string to initial state object accepted by the container.
* This is useful for deep linking when we need to handle the incoming URL.
*
* Example:
* @example
* ```js
* getStateFromPath(
* '/chat/jane/42',

View File

@@ -29,16 +29,21 @@ export type LinkingOptions = {
* Only applicable on Android and iOS.
*
* @example
* ```js
* {
* prefixes: [
* "https://example.com", // Exact
* "https://*.example.com" // Match with any subdomain
* "myapp://", // App-specific scheme
* "https://example.com", // Prefix for universal links
* "https://*.example.com" // Prefix which matches any subdomain
* ]
* }
* ```
*/
prefixes: string[];
/**
* Config to fine-tune how to parse the path.
*
* Example:
* @example
* ```js
* {
* Chat: {
@@ -52,13 +57,33 @@ export type LinkingOptions = {
/**
* Custom function to get the initial URL used for linking.
* Uses `Linking.getInitialURL()` by default.
* Not supported on the web.
* Not supported on Web.
*
* @example
* ```js
* {
* getInitialURL () => Linking.getInitialURL(),
* }
* ```
*/
getInitialURL?: () => Promise<string | null | undefined>;
/**
* Custom function to get subscribe to URL updates.
* Uses `Linking.addEventListener('url', callback)` by default.
* Not supported on the web.
* Not supported on Web.
*
* @example
* ```js
* {
* subscribe: (listener) => {
* const onReceiveURL = ({ url }) => listener(url);
*
* Linking.addEventListener('url', onReceiveURL);
*
* return () => Linking.removeEventListener('url', onReceiveURL);
* }
* }
* ```
*/
subscribe?: (
listener: (url: string) => void