NOTE: This log only reflects important changes related to all packages. The version here indicates the core
package version. For the full list of changes, please refer to the corresponding package changelogs.
- Add FallbackTransport and a new
@anycable/long-polling
package.
- Add
actioncable-v1-ext-json
protocol support.
- Dependencies upgrade and minor types changes.
core
: BREAKINGchannelsCache
is deprecated/removed in favour of support for using multiple channel instances for the same identifier.
Channels cache has been added as a workaround for automatically re-using the same channel instance to avoid double-subscrpition problems (since a single client may only have a single subscrpition for the specified identifier).
Not it's possible (and recommended) to create multiple channel instances, AnyCable client takes care of creating a single subscription under the hood. Each channel instance is independent, which means that, for example, calling channel.disconnect()
removes this channels from the subscribers list and no messages are sent to this particular instance (which could lead to an unexpected behaviour when channels cache was used).
core
: BREAKINGcable.subscribe(channel)
is now sync and returns the passed channel itself, so you can chain the execution. The actualsubscribe
command is sent asynchrounously.
If you still want to wait for channel to be connected, you can use the new ensureSubscribed
function:
# Before
await cable.subscribe(channel)
# After
await cable.subscribe(channel).ensureSubscribed()
Similarly, cable.subscribeTo(...)
is not longer async and returns the channel instance immediately. You can call channel.ensureSubscribed()
to make sure the channel has been connected to the server.
The channel.disconnect()
function is no longer async and has not return value. It records the intention to unsubscribe. The actual unsubscribe
command is sent asynchrounously (if requried, i.e., if there are no other channel instances with the same identifier).
-
core
: Standardizeclose
anddisconnect
events and the corresponding methods to always emit/return ReasonError instances (not just DisconnectEvents). Transport errors (e.g., connection failure) are now also wrapped intoDisconnectedError
with the reasontransport_close
. You can access the original error viaerror.cause
property. -
core
: Addedclosed
state to indicate that a cable or a channel was intentionally disconnected (by user or by server) without further reconnections.
Now disconnected
always implies reconnection (which might be done by a monitor).
core
: Makecable.subscribe(channel)
optimistic (i.e., wait for the cable to be connected, ignore "disconnected" state).
This makes it possible to use await cable.subscribe(channel)
and don't care about underlying cable state (unless it's closed manually or subscription is rejected).
The channel.disconnect()
works similarly in a sense that it considers lack of connection as success, and tries to send the unsubscribe
command otherwise.
-
Added optional memoization to
cable.subscribeTo
. (@palkan) -
Added
cable.subscribeTo(channelClass, params)
support. (@palkan) -
Support multiple
cable.subscribe(channel)
andcable.unsubscribe(identifier)
. (@palkan)
It is possible to reuse the same channel instance independently from different components. Each component takes care of subscribing and unsubsribing; the actual subscription (or unsubscription) only happens once.
- Added a cable implementation (
TestCable
) for unit testing purpose to@anycable/core
. (@TheSeally)
- Added
actioncable-v1-protobuf
support and@anycable/protobuf-encoder
package. (@charlie-wasp)
-
Added
tokenRefresher
option tocreateCable
to handletoken_expired
disconnections. (@palkan) -
Fix unhandled Promise rejection in Monitor. (@tienle, @gydroperit, @palkan)