2020-01-23 18:11:06 +01:00
|
|
|
import Nanobus = require('nanobus')
|
2017-10-05 16:51:09 -04:00
|
|
|
|
|
|
|
|
export = Choo
|
|
|
|
|
|
|
|
|
|
declare class Choo {
|
2017-10-18 20:44:59 +09:00
|
|
|
constructor (opts?: Choo.IChoo)
|
2020-01-23 18:11:06 +01:00
|
|
|
use (callback: (state: Choo.IState, emitter: Nanobus, app: this) => void): void
|
|
|
|
|
route (routeName: string, handler: (state: Choo.IState, emit: Nanobus['emit']) => void): void
|
2017-10-05 16:51:09 -04:00
|
|
|
mount (selector: string): void
|
|
|
|
|
start (): HTMLElement
|
|
|
|
|
toString (location: string, state?: Choo.IState): string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declare namespace Choo {
|
|
|
|
|
export interface IChoo {
|
|
|
|
|
history?: boolean
|
|
|
|
|
href?: boolean
|
2020-01-23 23:30:43 +08:00
|
|
|
hash?: boolean
|
2020-01-23 18:11:06 +01:00
|
|
|
cache?: number | ICache
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ICache {
|
|
|
|
|
get(id: string | number): undefined | null | any
|
|
|
|
|
set(id: string | number, element: any): void
|
2017-10-05 16:51:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IState {
|
|
|
|
|
events: {
|
|
|
|
|
[key: string]: string
|
|
|
|
|
}
|
|
|
|
|
params: {
|
|
|
|
|
[key: string]: string
|
|
|
|
|
}
|
|
|
|
|
query?: {
|
|
|
|
|
[key: string]: string
|
|
|
|
|
}
|
|
|
|
|
href: string
|
|
|
|
|
route: string
|
|
|
|
|
title: string
|
|
|
|
|
[key: string]: any
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|