@@ -1296,11 +1296,17 @@ defmodule GenStage do
1296
1296
end
1297
1297
1298
1298
@ 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.
1300
1301
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.
1302
1304
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.
1304
1310
"""
1305
1311
@ spec sync_resubscribe ( stage , subscription_tag , term , subscription_options , timeout ) ::
1306
1312
{ :ok , subscription_tag } | { :error , :not_a_consumer } | { :error , { :bad_opts , String . t ( ) } }
@@ -1320,24 +1326,34 @@ defmodule GenStage do
1320
1326
@ doc """
1321
1327
Asks the consumer to subscribe to the given producer asynchronously.
1322
1328
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.
1326
1333
1327
1334
## Options
1328
1335
1329
- This function accepts the same options as `sync_subscribe/4 `.
1336
+ This function accepts the same options as `sync_subscribe/2 `.
1330
1337
"""
1331
1338
@ spec async_subscribe ( stage , subscription_options ) :: :ok
1332
1339
def async_subscribe ( stage , opts ) do
1333
1340
async_subscribe ( stage , nil , opts )
1334
1341
end
1335
1342
1336
1343
@ 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
1339
1355
1340
- See `async_subscribe/2` for examples and options.
1356
+ This function accepts the same options as `sync_subscribe/2` .
1341
1357
"""
1342
1358
@ spec async_resubscribe ( stage , subscription_tag , reason :: term , subscription_options ) :: :ok
1343
1359
def async_resubscribe ( stage , subscription_tag , reason , opts ) do
0 commit comments