Repository navigation
feat: 🎸 dynamic base url and custom websocket message format - #149
Merged
Merged
Conversation
Add client.setUrl(url, { abort, invalidate }) to switch the base url at runtime.
Cache keys do not include the base url, so abort/invalidate let callers drop
in-flight requests and stale data of the previous server.
cache.invalidate() called without arguments now invalidates every entry.
Refs #148
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add socket.setUrl(url) - applied on the next connection attempt, like
setQueryParams. Add flat decode/encode options to the websocket adapter and
decode to the SSE adapter, so servers using a custom frame shape
(e.g. { type, payload }) work without a custom adapter. Frames decoded to null
are ignored; encode/decode errors are reported through onError.
Closes #148
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 9.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #148
Core
client.setUrl(url, { abort?, invalidate? })switches the base URL at runtime. Cache keys don't include the base URL, so:abortcancels in-flight requests sent to the previous URLinvalidateinvalidates the whole cache, plus the aborted requests, so mounted hooks refetch from the new URLfalse, and calling it with the current URL does nothingclient.cache.invalidate()with no arguments now invalidates every entry.Sockets
socket.setUrl(url)applies to the next connection attempt, the same waysetQueryParamsdoes. Callreconnect()to apply it to a live connection. Listeners stay registered.WebsocketAdapterhas two new flat options:decode(event) => { topic, data } | nullmaps incoming frames; returningnullignores the frameencode({ topic, payload }) => framemaps outgoing frames, including heartbeat messagesServerSentEventsAdaptergets the same flatdecodeoption.encodeordecodeare reported throughonErrorand don't break the connection. When the options are not set, frames keep the current{ topic, data }shape.Docs are updated for the client, cache, socket and adapter pages.
Tests
client.set-url.spec.ts(new) and acache.invalidate()no-argument caseadapter.websocket.codec.spec.tsandadapter.sse.codec.spec.ts(new), plussetUrltests insocket.methods.spec.ts, including reconnecting to a second server🤖 Generated with Claude Code