media-stream-player-js icon indicating copy to clipboard operation
media-stream-player-js copied to clipboard

Stats: why do you need to pass all the props

Open anius opened this issue 5 years ago • 2 comments

Hello,

  1. As a developer I'm wondering why all these props are need to be passed Stats component: Screenshot 2020-12-09 at 19 53 03

IMO all these props should already be present in the player and be accessible via state, context API, recoil, osv and should not be passed to the component to prevent the player and stats to be not in sync.

  1. IMO api is confusing name for the prop also and IMO you should have comments above the props types in order to display hints in VS Code and help the developers to understand what the prop does, e.g.:,
Screenshot 2020-12-10 at 12 32 16 Screenshot 2020-12-10 at 12 32 25

anius avatar Dec 10 '20 11:12 anius

True, currently everything is passed as props down to each component. Now that this has grown it might be a good idea to combine player state into a context, and use that within the major components such as PlaybackArea, Stats, Controls. If you implement your own Player, it's then up to you to provide the same context. Lower-level components should probably keep the props (and not depend on the context).

At first glance, some things that could end up in a context would be:

{
play, setPlay,
refresh, setRefresh,
host, setHost,
api, setApi,
parameters, setParameters,
volume, setVolume,
videoProperties, setVideoProperties
}

steabert avatar Dec 10 '20 11:12 steabert

All valid concerns. We'll take a look at this.

lekoaf avatar Dec 10 '20 11:12 lekoaf