Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Using AbortControllers with Spotify SDK

Using AbortControllers with Spotify SDK

Plan

Premium

Country

United States

 

Device

MacBook Pro 2020 T2

Operating System

macOS Monterey

 

My Question or Issue

I'm curious if anyone has experience using signals and/or AbortController() with the Spotify SDK's addListener and removeListener functionality to programmatically cancel listeners.

 

I'm working on a React app that plays Spotify songs requested via PUT request to the Spotify API, then played and paused through the SDK. At the moment, I have a roughly cobbled-together listener for track end (please create a dedicated SDK track-end listener, Spotify) that listens for changes to player_state, and if a series of changes occur to state, then the listener invokes a callback to request the next track.

 

At the moment, this listener registers each time a Spotify track is played, resulting in a ridiculous number of listeners if a user plays a series of songs. Does anyone have experience canceling these with an AbortController? And if so, how would one do so, since the SDK listener doesn't accept an options object?

Reply
0 Replies

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random

Type a product name