8000 TypeScript: appState instance type added · vanioinformatika/node-appstate@a71eed5 · GitHub
[go: up one dir, main page]

Skip to content

Commit a71eed5

Browse files
committed
TypeScript: appState instance type added
1 parent 0b85f0a commit a71eed5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

appState.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
declare interface StateHandler {
22
(appState: string, newAppState: string): void
3-
}
4-
declare function appState(stateHandler: StateHandler): void
3+
}
4+
declare function appState(stateHandler: StateHandler): appState.AppStateInstance
55

66
declare namespace appState {
7+
interface AppStateInstance {}
78
// Application is under initialization.
89
function init(): void
910
// Application is running.

appState.d.ts.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import * as AppState from '.'
2+
import { AppStateInstance } from '.'
23

34
// init application state handler with logging
4-
AppState(
5+
export const appStateInstance: AppStateInstance = AppState(
56
(appState: string, newAppState: string): void => {
67
if (AppState.isError() || AppState.isFatal()) {
7-
console.error({ details: `${appState} to ${newAppState}` }, 'appstate')
8+
console.error(`appstate ${appState} to ${newAppState}`)
89
} else {
9-
console.warn({ details: `${appState} to ${newAppState}` }, 'appstate')
10+
console.warn(`appstate ${appState} to ${newAppState}`)
1011
}
1112
},
1213
)

0 commit comments

Comments
 (0)
0