Skip to content

Commit

Permalink
Include :noreply return types in custom callbacks
Browse files Browse the repository at this point in the history
Connects #71
  • Loading branch information
the-mikedavis committed Dec 3, 2024
1 parent d575361 commit 67afbe8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## UNRELEASED

### Fixed

- Fixed callback return types to include `{:noreply, new_socket}` and
`{:noreply, new_socket, _rest}` (for returning timeouts or triggering
`handle_continue/2` for example). These return types were always
supported but not declared in the callback, so the dialyzer would
complain if these values were returned.
- `c:Slipstream.handle_connect/1`
- `c:Slipstream.handle_disconnect/2`
- `c:Slipstream.handle_join/3`
- `c:Slipstream.handle_message/4`
- `c:Slipstream.handle_reply/3`
- `c:Slipstream.handle_topic_close/3`
- `c:Slipstream.handle_leave/2`

## 1.1.2 - 2024-09-26

### Added
Expand Down
23 changes: 22 additions & 1 deletion lib/slipstream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,15 @@ defmodule Slipstream do
@impl Slipstream
def handle_connect(socket) do
{:noreply, socket}
{:ok, socket}
end
"""
@doc since: "0.1.0"
@callback handle_connect(socket :: Socket.t()) ::
{:ok, new_socket}
| {:noreply, new_socket}
| {:noreply, new_socket,
timeout() | :hibernate | {:continue, term()}}
| {:stop, reason :: term(), new_socket}
when new_socket: Socket.t()

Expand All @@ -553,6 +556,9 @@ defmodule Slipstream do
@doc since: "0.1.0"
@callback handle_disconnect(reason :: term(), socket :: Socket.t()) ::
{:ok, new_socket}
| {:noreply, new_socket}
| {:noreply, new_socket,
timeout() | :hibernate | {:continue, term()}}
| {:stop, stop_reason :: term(), new_socket}
when new_socket: Socket.t()

Expand All @@ -575,6 +581,9 @@ defmodule Slipstream do
socket :: Socket.t()
) ::
{:ok, new_socket}
| {:noreply, new_socket}
| {:noreply, new_socket,
timeout() | :hibernate | {:continue, term()}}
| {:stop, reason :: term(), new_socket}
when new_socket: Socket.t()

Expand Down Expand Up @@ -605,6 +614,9 @@ defmodule Slipstream do
socket :: Socket.t()
) ::
{:ok, new_socket}
| {:noreply, new_socket}
| {:noreply, new_socket,
timeout() | :hibernate | {:continue, term()}}
| {:stop, reason :: term(), new_socket}
when new_socket: Socket.t()

Expand Down Expand Up @@ -638,6 +650,9 @@ defmodule Slipstream do
socket :: Socket.t()
) ::
{:ok, new_socket}
| {:noreply, new_socket}
| {:noreply, new_socket,
timeout() | :hibernate | {:continue, term()}}
| {:stop, reason :: term(), new_socket}
when new_socket: Socket.t()

Expand Down Expand Up @@ -665,6 +680,9 @@ defmodule Slipstream do
socket :: Socket.t()
) ::
{:ok, new_socket}
| {:noreply, new_socket}
| {:noreply, new_socket,
timeout() | :hibernate | {:continue, term()}}
| {:stop, stop_reason :: term(), new_socket}
when new_socket: Socket.t()

Expand All @@ -691,6 +709,9 @@ defmodule Slipstream do
socket :: Socket.t()
) ::
{:ok, new_socket}
| {:noreply, new_socket}
| {:noreply, new_socket,
timeout() | :hibernate | {:continue, term()}}
| {:stop, stop_reason :: term(), new_socket}
when new_socket: Socket.t()

Expand Down

0 comments on commit 67afbe8

Please sign in to comment.