Skip to content

Fetching data async to the stream #2

@clementsirieix

Description

@clementsirieix

In the Audio component: (this is written from head so maybe not exactly what already exists)

audioTimeout = null

componentWillMount() {
    const { fetchCurrentTrack } = this.props
    fetchCurrentTrack() // should be the first call of this action
}

componentWillReceiveProps(nextProps) {
    const { currentTrack, fetchCurrentTrack } = nextProps
    
    if (currentTrack.id !== this.props.currentTrack.id) {
         this.audioTimeout = setTimeout(() => fetchCurrentTrack(), currentTrack.duration)
    }
}

componentWillUnmount() {
    clearTimeout(this.audioTimeout) // stop memory leaks
}

This process should allow only the current track to be displayed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions