Skip to content

Commit

Permalink
Merge pull request #72 from MatthewWid/fix-default-state
Browse files Browse the repository at this point in the history
Fix default state being `unknown` when creating sessions and channels with factories
  • Loading branch information
MatthewWid authored Oct 17, 2024
2 parents 61adebd + c455b0e commit 5a66707
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

* Fixed default state type when creating sessions and channels with `createSession` and `createChannel` being set to `unknown` instead of `DefaultSessionState` and `DefaultChannelState`, respectively.

## 0.13.0 - 2024-08-23

### Added
Expand Down
8 changes: 6 additions & 2 deletions src/createChannel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import {Channel} from "./Channel";
import {Channel, DefaultChannelState} from "./Channel";
import {DefaultSessionState} from "./Session";

const createChannel = <State, SessionState>(
const createChannel = <
State = DefaultChannelState,
SessionState = DefaultSessionState,
>(
...args: ConstructorParameters<typeof Channel<State, SessionState>>
): Channel<State, SessionState> => new Channel<State, SessionState>(...args);

Expand Down
4 changes: 2 additions & 2 deletions src/createSession.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Session} from "./Session";
import {Session, DefaultSessionState} from "./Session";

/**
* Create a new session and return the session instance once it has connected.
*/
const createSession = <State>(
const createSession = <State = DefaultSessionState>(
...args: ConstructorParameters<typeof Session<State>>
): Promise<Session<State>> =>
new Promise((resolve) => {
Expand Down

0 comments on commit 5a66707

Please sign in to comment.