Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AUTOMATED] Update files from 0xsequence/indexer #683

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

0xsequence-bot
Copy link
Contributor

@0xsequence-bot 0xsequence-bot requested review from a team as code owners February 26, 2025 16:22
Comment on lines +1319 to +1356
subscribeEvents = (args: SubscribeEventsArgs, options: WebrpcStreamOptions<SubscribeEventsReturn>): WebrpcStreamController => {
const abortController = new AbortController()
const abortSignal = abortController.signal

if (options.signal) {
abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), {
signal: options.signal
})
}

const _fetch = () =>
this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, options.signal)).then(
this.fetch(this.url('SubscribeEvents'), createHTTPRequest(args, options.headers, abortSignal)).then(
async res => {
await sseResponse(res, options, _fetch)
},
error => {
options.onError(error, _fetch)
}
)
return _fetch()

const resp = _fetch()
return {
abort: abortController.abort.bind(abortController),
closed: resp
}
}
subscribeBalanceUpdates = (
args: SubscribeBalanceUpdatesArgs,
options: WebrpcStreamOptions<SubscribeBalanceUpdatesReturn>
): Promise<void> => {
): WebrpcStreamController => {
const abortController = new AbortController()
const abortSignal = abortController.signal

if (options.signal) {
abortSignal.addEventListener('abort', () => abortController.abort(options.signal?.reason), {
signal: options.signal
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiam few improvements to our webrpc streaming API in TypeScript based on webrpc/webrpc#311. Can you take this for a spin please?

@xiam
Copy link
Contributor

xiam commented Mar 10, 2025

More details on the expectations of this task:

Vojtech: Can you please go through the streaming examples in our docs:
https://docs.sequence.xyz/api/indexer/examples/subscriptions#subscriptions
and make sure they work with the recent changes in this PR?
The changes were only cosmetic and I believe they were backward compatible. But let's double check please.
Also, I think we could improve the TypeScript example, since we now return WebrpcStreamController, which lets you abort the stream.. or use closed() promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants