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.
- Minor fixes
- Add
whisperto Action Cable compatibility. (@palkan)
- Improve Action Cable JS/TS compatibility. (@palkan)
-
Add
disableSessionRecoveryoption for extended protocol. (@palkan) -
Prevent session recovery after
disconnectmessage is received. (@palkan)
- Added
reconnectedflag to Action Cable connected callback payload. (@d4rky-pl )
-
Add
websocketAuthStrategyoption tocreateCableto specify how to pass a token for WebSocket connections (using a query param, a header, or a sub-protocol). (@palkan) -
Add
auth: {token: '...'}option tocreateCableto pass the initial authentiation token. (@palkan) -
Add
transportConfiguratorparameter tocreateCableto perform arbitrary transport modifications (like, fetching the initial token) before opening a connection. (@palkan)
- Add
performFailures: 'throw' | 'warn' | 'ignore'option tocreateCable(). (@palkan)
-
Add
infoevent to Cable and Channel. (@palkan)This event can be used to notify of some protocol-level events that happen under the hood and have no representation at the Channel API level. A example of such event is a stream history retrieval failure (
{type: "history_not_found"}).
-
Types improvements. (@cmdoptesc)
-
Node 18+ is required.
-
Added
channel.whisper(...). (@palkan)Clients can send transient publications to channels via whispering. NOTE: it must be supported by the server and enabled for the channel. See docs.
-
Added AnyCable signed streams support. (@palkan)
Two new methods have been added to connect to streams directly without any channels:
cable.streamFrom(name)andcable.streamFromSigned(signedName). See signed streams docs.
- Omit
undefinedin serialized channel identifiers. (@ardecvz)
-
Add ActionsType to
Channelclass. (@palkan)Now you can specify which actions can be performed by the channel.
- Add FallbackTransport and a new
@anycable/long-pollingpackage.
- Add
actioncable-v1-ext-jsonprotocol support.
- Dependencies upgrade and minor types changes.
core: BREAKINGchannelsCacheis 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 actualsubscribecommand 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: Standardizecloseanddisconnectevents and the corresponding methods to always emit/return ReasonError instances (not just DisconnectEvents). Transport errors (e.g., connection failure) are now also wrapped intoDisconnectedErrorwith the reasontransport_close. You can access the original error viaerror.causeproperty. -
core: Addedclosedstate 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-protobufsupport and@anycable/protobuf-encoderpackage. (@charlie-wasp)
-
Added
tokenRefresheroption tocreateCableto handletoken_expireddisconnections. (@palkan) -
Fix unhandled Promise rejection in Monitor. (@tienle, @gydroperit, @palkan)