Skip to content

Commit

Permalink
remove circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousme committed Nov 2, 2024
1 parent 0b28020 commit f4fade7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
10 changes: 10 additions & 0 deletions client/ConnectionState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const ConnectionState = {
offline: "offline",
connecting: "connecting",
connected: "connected",
disconnecting: "disconnecting",
disconnected: "disconnected",
} as const;

export type TConnectionState =
(typeof ConnectionState)[keyof typeof ConnectionState];
13 changes: 2 additions & 11 deletions client/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,8 @@ import {
} from "./deps.ts";

import { handlePacket } from "./handlers/handlePacket.ts";

export const ConnectionState = {
offline: "offline",
connecting: "connecting",
connected: "connected",
disconnecting: "disconnecting",
disconnected: "disconnected",
} as const;

export type TConnectionState =
typeof ConnectionState[keyof typeof ConnectionState];
import type { TConnectionState } from "./ConnectionState.ts";
import { ConnectionState } from "./ConnectionState.ts";

export class Context {
mqttConn?: MqttConn;
Expand Down
3 changes: 2 additions & 1 deletion client/handlers/handleConnack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConnectionState, type Context } from "../context.ts";
import type { Context } from "../context.ts";
import { ConnectionState } from "../ConnectionState.ts";
import { AuthenticationResultByNumber, type ConnackPacket } from "../deps.ts";

export async function handleConnack(packet: ConnackPacket, ctx: Context) {
Expand Down
3 changes: 2 additions & 1 deletion client/handlers/handlePacket.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConnectionState, type Context } from "../context.ts";
import type { Context } from "../context.ts";
import { ConnectionState } from "../ConnectionState.ts";
import { handleConnack } from "./handleConnack.ts";
import { handlePublish } from "./handlePublish.ts";
import { handlePuback } from "./handlePuback.ts";
Expand Down

0 comments on commit f4fade7

Please sign in to comment.