function usePlaylistListSync
usePlaylistListSync(
items: Playlist[],
setPlaylists: (fn: (prev: Playlist[]) => Playlist[]) => void,
): void

Applies the socket's playlist events to items, the loaded list, which setPlaylists updates. A created playlist goes where the list's order puts it, an updated one changes in place or leaves when it turns private (unless isOwner), one that left comes back where it was when it returns, a deleted one leaves, and a playlist's dumpCount and lastDumpAt follow its dumps. One that a change brings up the order moves up to its place, as a playlist does in the updated order when it takes a dump; one that falls stays where it is, its place being perhaps on a page not loaded. A renamed user's playlists take their new name.

Parameters

items: Playlist[]
setPlaylists: (fn: (prev: Playlist[]) => Playlist[]) => void
optional
options: PlaylistListSyncOptions

Return Type

void

Usage

import { usePlaylistListSync } from "src/hooks/playlist/usePlaylistListSync.ts";