Simplify tick.ts typing
This commit is contained in:
parent
063dd636bb
commit
b05cdab771
1 changed files with 2 additions and 6 deletions
|
@ -1,13 +1,9 @@
|
||||||
import { Cancel, Source } from "./source";
|
import { Source } from "./source";
|
||||||
|
|
||||||
export type PhysicsTick = ["physics"];
|
export type PhysicsTick = ["physics"];
|
||||||
export type RenderTick = ["render", number];
|
export type RenderTick = ["render", number];
|
||||||
|
|
||||||
export function tick(fps: number): Source<PhysicsTick | RenderTick> {
|
export function tick(fps: number): Source<PhysicsTick | RenderTick> {
|
||||||
function tickSource(): PhysicsTick;
|
|
||||||
function tickSource(
|
|
||||||
callback: (tick: PhysicsTick | RenderTick) => void
|
|
||||||
): Cancel;
|
|
||||||
function tickSource(callback?: (tick: PhysicsTick | RenderTick) => void) {
|
function tickSource(callback?: (tick: PhysicsTick | RenderTick) => void) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
let lastPhysicsTick: number = new Date().getTime();
|
let lastPhysicsTick: number = new Date().getTime();
|
||||||
|
@ -32,5 +28,5 @@ export function tick(fps: number): Source<PhysicsTick | RenderTick> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tickSource;
|
return tickSource as Source<PhysicsTick | RenderTick>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue