chore: make Rehydratable use Awaitable; add docblock
This commit is contained in:
parent
cf6d14abca
commit
5d960e6186
@ -1,11 +1,13 @@
|
|||||||
import {Dispatchable} from './types'
|
import {Dispatchable} from './types'
|
||||||
import {JSONState} from '../util'
|
import {Awaitable, JSONState} from '../util'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class representing an event that may be fired.
|
* Abstract class representing an event that may be fired.
|
||||||
*/
|
*/
|
||||||
export abstract class Event implements Dispatchable {
|
export abstract class Event implements Dispatchable {
|
||||||
abstract dehydrate(): Promise<JSONState>
|
|
||||||
|
|
||||||
abstract rehydrate(state: JSONState): void | Promise<void>
|
|
||||||
|
abstract dehydrate(): Awaitable<JSONState>
|
||||||
|
|
||||||
|
abstract rehydrate(state: JSONState): Awaitable<void>
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,14 @@ export class Routing extends Unit {
|
|||||||
return this.compiledRoutes
|
return this.compiledRoutes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a UniversalPath to a file served as an asset.
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* this.getAssetPath('images', '123.jpg').toRemote // => http://localhost:8000/assets/images/123.jpg
|
||||||
|
* ```
|
||||||
|
* @param parts
|
||||||
|
*/
|
||||||
public getAssetPath(...parts: string[]): UniversalPath {
|
public getAssetPath(...parts: string[]): UniversalPath {
|
||||||
return this.getAssetBase().concat(...parts)
|
return this.getAssetBase().concat(...parts)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* Type representing a JSON serializable object.
|
* Type representing a JSON serializable object.
|
||||||
*/
|
*/
|
||||||
import {ErrorWithContext} from '../error/ErrorWithContext'
|
import {ErrorWithContext} from '../error/ErrorWithContext'
|
||||||
|
import {Awaitable} from './types'
|
||||||
|
|
||||||
export type JSONState = { [key: string]: string | boolean | number | undefined | JSONState | Array<string | boolean | number | undefined | JSONState> }
|
export type JSONState = { [key: string]: string | boolean | number | undefined | JSONState | Array<string | boolean | number | undefined | JSONState> }
|
||||||
|
|
||||||
@ -30,14 +31,14 @@ export function isJSONState(what: unknown): what is JSONState {
|
|||||||
export interface Rehydratable {
|
export interface Rehydratable {
|
||||||
/**
|
/**
|
||||||
* Dehydrate this class' state and get it.
|
* Dehydrate this class' state and get it.
|
||||||
* @return Promise<JSONState>
|
* @return JSONState|Promise<JSONState>
|
||||||
*/
|
*/
|
||||||
dehydrate(): Promise<JSONState>
|
dehydrate(): Awaitable<JSONState>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rehydrate a state into this class.
|
* Rehydrate a state into this class.
|
||||||
* @param {JSONState} state
|
* @param {JSONState} state
|
||||||
* @return void|Promise<void>
|
* @return void|Promise<void>
|
||||||
*/
|
*/
|
||||||
rehydrate(state: JSONState): void | Promise<void>
|
rehydrate(state: JSONState): Awaitable<void>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user