Our extended protocol supports automatic stream history retrieval but we do not provide any APIs to react on the corresponding events (more precisely, protocol messages: confirm_history and reject_history).
This PR introduces a new info event for cables and channels that can be used to signal arbitrary protocol-level events to users, including history_not_found and history_received events:
import { createCable, Channel } from '@anycable/web'
const cable = createCable({protocol: 'actioncable-v1-ext-json'});
const ch = cable.subscribeTo("ChatChannel");
ch.on("info", (evt) => {
if (evt.type === "history_not_found") {
// Restore state by performing an action
ch.perform("resetState")
// Or hard-reset the clients by reloading the page
window.location.reload();
}
// Successful history retrieval is also notified
if (evt.type === "history_received") {
// ...
}
});
Context
Our extended protocol supports automatic stream history retrieval but we do not provide any APIs to react on the corresponding events (more precisely, protocol messages:
confirm_history
andreject_history
).This PR introduces a new
info
event for cables and channels that can be used to signal arbitrary protocol-level events to users, includinghistory_not_found
andhistory_received
events: