diff options
| author | Melonai <einebeere@gmail.com> | 2021-06-03 15:37:52 +0200 |
|---|---|---|
| committer | Melonai <einebeere@gmail.com> | 2021-06-03 15:37:52 +0200 |
| commit | 631a39aecacf6e62ddc13ad4c8f3c81a0f5f49c7 (patch) | |
| tree | f2a457b8dcea5a272ab0bdc13f5fe6dde7f1fd28 /assets/src/network/channel/connection.ts | |
| parent | 1348f3402c9c15c37501c7cf48f6c63ae7f8c1d8 (diff) | |
| download | rook-631a39aecacf6e62ddc13ad4c8f3c81a0f5f49c7.tar.zst rook-631a39aecacf6e62ddc13ad4c8f3c81a0f5f49c7.zip | |
Remove circular channel dependency
Diffstat (limited to 'assets/src/network/channel/connection.ts')
| -rw-r--r-- | assets/src/network/channel/connection.ts | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/assets/src/network/channel/connection.ts b/assets/src/network/channel/connection.ts index 6d6f3de..59eb633 100644 --- a/assets/src/network/channel/connection.ts +++ b/assets/src/network/channel/connection.ts @@ -69,7 +69,13 @@ export function onWithToken<Message extends AnyMessage>( token: string | null, handler: Handler<Message> ): UnregisterHandler { - return registerTokenHandler(connection.handlers, event, token, handler); + return registerTokenHandler( + connection.handlers, + connection.channel, + event, + token, + handler + ); } export function on<Message extends AnyMessage>( @@ -87,14 +93,6 @@ export function getOwnToken(): string { return connection.token; } -export function getChannel(): Channel { - if (connection.state <= ConnectionState.FETCHING_TOKEN) { - throw new Error("There is no channel yet."); - } - - return connection.channel; -} - function updateState(state: ConnectionState) { // TODO: Notify state listeners connection.state = state; |
