Global Feed WebSocket Guide
The global feed (room global:feed) is one subscription that delivers a summary of every token and the
site-wide switches, without joining each token's own room. It is what a homepage or a listing uses.
What it carries
Token events (the same payloads as in the token room; see RealtimeEventPayloads):
| Event | Callback key | Payload type |
|---|---|---|
STREAM_STATUS | onStreamStatus | StreamStatusEvent |
TRADE_EXECUTED | onTradeExecuted | TradeExecutedEvent (tradeType is BUY/SELL, inputAmount, outputAmount, symbol?, icon?) |
HOLDER_COUNT_UPDATED | onHolderCountUpdated | HolderCountUpdatedEvent |
POOL_BADGE_ASSIGNED | onPoolBadgeAssigned | PoolBadgeAssignedEvent (badge is a string) |
VIEWER_COUNT | onViewerCount | ViewerCountEvent |
TOKEN_CONFIG_UPDATED | onTokenConfigUpdated | TokenConfigUpdatedEvent (only the changed fields) |
STATS_UPDATED | onStatsUpdated | StatsUpdatedEvent |
POOL_CREATED | onPoolCreated | PoolCreatedEvent |
Site-wide switches: SITE_CONFIG_CHANGED (onSiteConfigChanged, { key, value }) and the feature
switches STREAM_GLOBAL_STATUS, STREAM_CHAT_GLOBAL_STATUS, COMMENTS_GLOBAL_STATUS,
WEBHOOKS_GLOBAL_STATUS, AI_MODERATION_GLOBAL_STATUS (onStreamGlobalStatus, onStreamChatGlobalStatus,
onCommentsGlobalStatus, onWebhooksGlobalStatus, onAIModerationGlobalStatus, each { enabled }).
getSiteConfigState() returns the latest value of each switch since the feed was joined.
The feed has no filters: filter by tokenName in the callback.
Subscribing
import { StreamWebSocketService, getEnvironmentConfig } from '@gala-chain/launchpad-sdk';
const service = new StreamWebSocketService({ url: getEnvironmentConfig('prod').launchpadBaseUrl });
// Registers, opens the socket, joins the feed once connected. Returns THIS subscription's unsubscribe.
const unsubscribe = service.subscribeToGlobalFeed({
onStreamStatus: (event) => console.log(`${event.tokenName}: ${event.status}`),
onTradeExecuted: (event) => console.log(`${event.tradeType} ${event.inputAmount} ${event.tokenName}`),
onStreamGlobalStatus: (event) => console.log(`streaming ${event.enabled ? 'on' : 'off'}`),
});
// later
unsubscribe();
service.disconnect();
With a LaunchpadSDK, use sdk.realtime (the same service, built with your URL, your reconnect settings
and your session's token).
Other ways to subscribe to the feed, all sharing the one room:
- one event:
subscribeStatsUpdated,subscribePoolCreated,subscribeStreamGlobalStatus,subscribeChatGlobalStatus,subscribeCommentsGlobalStatus,subscribeWebhooksGlobalStatus,subscribeAIModerationGlobalStatus,subscribeSiteConfigChanged, orsubscribeFeed(event, listener); - every token event through one callback:
subscribeFeedTokenEvents((feedEvent) => ...), wherefeedEventis{ event: 'TRADE_EXECUTED', data: TradeExecutedEvent }or one of the other seven (tell them apart byevent, not by the shape ofdata).
Rules the service keeps
- Any number of subscribers. Each call is its own subscriber; none replaces another. The feed room is joined on the first and left on the last, never twice.
- Feed subscribers are served whether or not the token's room is joined. The server sends one copy of an event to a client that is in both rooms; the service delivers it to the token subscribers and to the feed subscribers.
- A subscriber that throws (or returns a rejecting promise) is logged and skipped; the others are served.
- Reconnects. After a reconnect the service re-authenticates (if it was authenticated), re-joins the
feed, then calls
onReconnectlisteners; refetch there what you missed. - POOL_CREATED reaches the feed and the overseer room: an overseer in both gets it once.
See also
- Authentication
- Quick start
examples/global-feed-demo.ts,examples/global-feed-filtering-demo.ts,examples/site-config-demo.ts