Skip to content

Commit f07399e

Browse files
author
José Valim
committed
Improve docs
1 parent 9050f02 commit f07399e

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

lib/gen_stage.ex

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,11 +1296,17 @@ defmodule GenStage do
12961296
end
12971297

12981298
@doc """
1299-
Cancels `subscription_tag` with `reason` and subscribes synchronously in one step.
1299+
Cancels `subscription_tag` with `reason` and resubscribe
1300+
to the same stage with the given options.
13001301
1301-
`subscription_tag` is the subscription tag returned by `sync_subscribe/3`.
1302+
This is useful in case you need to update the options in
1303+
which you are currently subscribed to in a producer.
13021304
1303-
See `sync_subscribe/3` for examples and options.
1305+
This function is sync, which means it will wait until the
1306+
subscription message is sent to the producer, although it
1307+
won't wait for the subscription confirmation.
1308+
1309+
See `sync_subscribe/2` for options and more information.
13041310
"""
13051311
@spec sync_resubscribe(stage, subscription_tag, term, subscription_options, timeout) ::
13061312
{:ok, subscription_tag} | {:error, :not_a_consumer} | {:error, {:bad_opts, String.t()}}
@@ -1320,24 +1326,34 @@ defmodule GenStage do
13201326
@doc """
13211327
Asks the consumer to subscribe to the given producer asynchronously.
13221328
1323-
This call returns `:ok` regardless if the subscription
1324-
effectively happened or not. It is typically called from
1325-
a stage's `c:init/1` callback.
1329+
This function is async, which means it always returns
1330+
`:ok` once the request is dispatched but without waiting
1331+
for its completion. This particular function is usually
1332+
called from a stage's `c:init/1` callback.
13261333
13271334
## Options
13281335
1329-
This function accepts the same options as `sync_subscribe/4`.
1336+
This function accepts the same options as `sync_subscribe/2`.
13301337
"""
13311338
@spec async_subscribe(stage, subscription_options) :: :ok
13321339
def async_subscribe(stage, opts) do
13331340
async_subscribe(stage, nil, opts)
13341341
end
13351342

13361343
@doc """
1337-
Cancels `subscription_tag` with `reason` and subscribe asynchronously in one
1338-
step.
1344+
Cancels `subscription_tag` with `reason` and resubscribe
1345+
to the same stage with the given options.
1346+
1347+
This is useful in case you need to update the options in
1348+
which you are currently subscribed to in a producer.
1349+
1350+
This function is async, which means it always returns
1351+
`:ok` once the request is dispatched but without waiting
1352+
for its completion.
1353+
1354+
## Options
13391355
1340-
See `async_subscribe/2` for examples and options.
1356+
This function accepts the same options as `sync_subscribe/2`.
13411357
"""
13421358
@spec async_resubscribe(stage, subscription_tag, reason :: term, subscription_options) :: :ok
13431359
def async_resubscribe(stage, subscription_tag, reason, opts) do

0 commit comments

Comments
 (0)