Using AbortControllers with Spotify SDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Labels:
-
Discussion
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page