Skip to content

Commit

Permalink
docs: wrote documentation for navigating between screens
Browse files Browse the repository at this point in the history
  • Loading branch information
itssamuelrowe committed May 10, 2022
1 parent 8bbf66e commit 8aec2df
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions docs/apps/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,49 @@
In Hypertool, your app can contain several screens. Each screen is located using
its route, that is, the slug.

## Navigating Between Screens

You can navigate between screens using the `context.navigate` function.
It has two signatures:

```typescript
interface IPath {
/**
* The path component in the URL, beginning with a `/`.
*/
path: string;

/**
* The query string component in the URL, beginning with a `?`.
*/
query: string;

/**
* A URL fragment identifier, beginning with a `#`.
*/
hash: string;
}

/**
* Describes a location that is the destination of some navigation.
* It can either be a URL or pieces of a URL.
*/
type TNavigationTarget = string | Partial<IPath>;

interface TNavigateFunction {
(target: TNavigationTarget, options?: INavigationOptions): void;
(delta: number): void;
}
```

The first function accepts the target to navigate to, which can be a URL
or pieces of a URL (partial `IPath`). Optionally, you can specify the `replace`
and `state` values.

The second function accepts the delta, that is, the number of steps you want to
go in the history stack. For example, `context.navigate(-1)` is equivalent to
hitting the back button once.

## Accessing Path Parameters

A common requirement for apps is to pass information between different screens.
Expand Down
2 changes: 1 addition & 1 deletion docs/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
- [Introduction](apps/introduction.md)
- [Activity Logs](apps/activity-logs.md)
- [Working with Screens](apps/working-with-screens.md)
- [Routing](apps/routing.md)
- [Working with Controllers](apps/working-with-controllers.md)
- [Routing](apps/routing.md)

## Working with Data

Expand Down

0 comments on commit 8aec2df

Please sign in to comment.