Skip to content

Commit

Permalink
fix: generalize typings on state renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Jul 4, 2019
1 parent 9c8fc1f commit 5cd8235
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
5 changes: 2 additions & 3 deletions packages/stencil-xstate-router/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
import {
ComponentRenderer,
NavigationHandler,
RouteEvent,
RouteHandler,
RouterInterpreterOptions,
StateRenderer,
Expand Down Expand Up @@ -86,7 +85,7 @@ export namespace Components {
/**
* State renderer
*/
'stateRenderer'?: StateRenderer<any, any, RouteEvent>;
'stateRenderer'?: StateRenderer<any, any, EventObject>;
/**
* If useHash set to true then the router uses an old routing approach with hash in the URL. Fall back to this mode if there is no History API supported.
*/
Expand Down Expand Up @@ -181,7 +180,7 @@ declare namespace LocalJSX {
/**
* State renderer
*/
'stateRenderer'?: StateRenderer<any, any, RouteEvent>;
'stateRenderer'?: StateRenderer<any, any, EventObject>;
/**
* If useHash set to true then the router uses an old routing approach with hash in the URL. Fall back to this mode if there is no History API supported.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

## Properties

| Property | Attribute | Description | Type | Default |
| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
| `capture` | `capture` | Capture clicks from child elements and convert to routes | `boolean` | `true` |
| `componentRenderer` | -- | Component renderer | `(component: string, props?: ComponentProps<any, any, EventObject>) => Element \| Element[]` | `undefined` |
| `hash` | `hash` | The hash parameter allows you to configure the hash character | `string` | `'#'` |
| `machine` _(required)_ | -- | An XState machine | `StateMachine<any, any, EventObject>` | `undefined` |
| `options` | -- | Interpreter options | `RouterInterpreterOptions` | `undefined` |
| `root` | `root` | The main URL of your application. | `string` | `undefined` |
| `routes` | -- | Routes to register | `{ [x: string]: string; }` | `undefined` |
| `stateRenderer` | -- | State renderer | `(component: Element \| Element[], current: State<any, RouteEvent>, send: (event: SingleOrArray<OmniEvent<RouteEvent>>, payload?: Record<string, any> & { type?: undefined; }) => State<any, RouteEvent>, service: Interpreter<any, any, RouteEvent>) => Element \| Element[]` | `undefined` |
| `useHash` | `use-hash` | If useHash set to true then the router uses an old routing approach with hash in the URL. Fall back to this mode if there is no History API supported. | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `capture` | `capture` | Capture clicks from child elements and convert to routes | `boolean` | `true` |
| `componentRenderer` | -- | Component renderer | `(component: string, props?: ComponentProps<any, any, EventObject>) => Element \| Element[]` | `undefined` |
| `hash` | `hash` | The hash parameter allows you to configure the hash character | `string` | `'#'` |
| `machine` _(required)_ | -- | An XState machine | `StateMachine<any, any, EventObject>` | `undefined` |
| `options` | -- | Interpreter options | `RouterInterpreterOptions` | `undefined` |
| `root` | `root` | The main URL of your application. | `string` | `undefined` |
| `routes` | -- | Routes to register | `{ [x: string]: string; }` | `undefined` |
| `stateRenderer` | -- | State renderer | `(component: Element \| Element[], state: State<any, EventObject>, send: (event: SingleOrArray<OmniEvent<EventObject>>, payload?: Record<string, any> & { type?: undefined; }) => State<any, EventObject>, service: Interpreter<any, any, EventObject>) => Element \| Element[]` | `undefined` |
| `useHash` | `use-hash` | If useHash set to true then the router uses an old routing approach with hash in the URL. Fall back to this mode if there is no History API supported. | `boolean` | `false` |


## Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Navigo from 'navigo';
import { EventObject, StateMachine } from 'xstate';
import {
ComponentRenderer,
RouteEvent,
RouterInterpreterOptions,
StateRenderer
} from '../xstate-router/types';
Expand Down Expand Up @@ -53,7 +52,7 @@ export class XstateRouterNavigo implements ComponentInterface {
/**
* State renderer
*/
@Prop() stateRenderer?: StateRenderer<any, any, RouteEvent>;
@Prop() stateRenderer?: StateRenderer<any, any, EventObject>;

/**
* Component renderer
Expand Down

0 comments on commit 5cd8235

Please sign in to comment.