Skip to content

Commit

Permalink
nit: support async too
Browse files Browse the repository at this point in the history
  • Loading branch information
dalechyn committed Jul 24, 2024
1 parent 72dbade commit 3b81692
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/frog-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ export type FrogConstructorParameters<
* }
* ```
*/
initialState?: ((c: Context<env>) => _state) | _state | undefined
initialState?:
| ((c: Context<env>) => _state | Promise<_state>)
| _state
| undefined
/**
* Origin URL of the server instance.
*
Expand Down Expand Up @@ -264,7 +267,10 @@ export class FrogBase<
> {
// Note: not using native `private` fields to avoid tslib being injected
// into bundled code.
_initialState: ((c: Context<env>) => _state) | _state | undefined = undefined
_initialState:
| ((c: Context<env>) => _state | Promise<_state>)
| _state
| undefined = undefined
/** Path for assets. */
assetsPath: string
/** Base path of the server instance. */
Expand Down Expand Up @@ -587,7 +593,7 @@ export class FrogBase<
}),
initialState:
typeof this._initialState === 'function'
? (this._initialState as any)(c)
? await (this._initialState as any)(c)
: this._initialState,
origin,
})
Expand Down Expand Up @@ -994,7 +1000,7 @@ export class FrogBase<
}),
initialState:
typeof this._initialState === 'function'
? (this._initialState as any)(c)
? await (this._initialState as any)(c)
: this._initialState,
})

Expand Down

0 comments on commit 3b81692

Please sign in to comment.