Prerequisites
Before starting, make sure you have:- Completed our TypeScript and Node.js Setup Guide.
Key Features
The ReStream client is built to handle the complexities of real-time data streaming so you can focus on your applicationβs logic.- Automatic Reconnection: The client automatically handles dropped connections with a configurable exponential backoff strategy, ensuring your application remains connected and resilient.
- Simple Subscription Management: An intuitive API allows you to subscribe and unsubscribe from data channels, with built-in support for wildcard subscriptions.
- Built-in Protobuf Decoding: Raw binary messages are automatically decoded into structured, type-safe TypeScript objects, removing the need for manual parsing.
- Type-Safe Handlers: Leverage TypeScript generics to ensure your event handlers receive data with the correct types, improving code quality and reducing runtime errors.
- Resilient and Configurable: The client is highly configurable, allowing you to adjust connection timeouts, ping intervals, subscription limits, and reconnection behavior.
Getting Started: A Basic Subscription Script
Here is a complete script that demonstrates the fundamental workflow: connecting to the service, subscribing to BAGS launches, handling incoming data, and disconnecting gracefully.stream-launches.ts
Subscription Methods
The SDK offers several ways to subscribe to channels, from generic to highly specific convenience methods.Generic Methods
These methods provide maximum flexibility for subscribing to any channel.-
subscribeTopic<T>(topic, subject, handler): The most common method. You provide the topic and subject separately. -
subscribe<T>(channel, handler):Use this when you have the full channel string.
Convenience Methods
For common use cases, the SDK provides helper methods that build the channel string for you.subscribeBagsLaunches(handler): Subscribes to new token launches on Bags.
streram-launches-convenient.tsx