streamlit-webrtc icon indicating copy to clipboard operation
streamlit-webrtc copied to clipboard

[Doc] Precisions on class callback VS function callback

Open Rom1deTroyes opened this issue 3 years ago • 2 comments

Hello,

The readme show examples with a callback function, and class-based callbacks seems to be outdated :

Class-based callbacks

Until v0.37, the class-based callbacks were the standard. See the old version of the README about it.

Do you means that function must be prefered, and class is an obsolete way way to use streamlit-webrtc ?

Is it worth to update legacy code and refactor classes to functions ?

I will be happy to contribute submitting a PR refrasing this part if you feel this disambiguation is needed :-)

Thanx for this awesome composant : it's just amazing how simple it make to play with video cam ideas :+1:

Rom1deTroyes avatar Oct 19 '22 08:10 Rom1deTroyes

Hi, thank you for the critical question. Yes, as you said, I recommend the function-based API and would like to deprecate the class-based one.

Is it worth to update legacy code and refactor classes to functions ?

Removing the class-based API will be a breaking change, so it would be at the next major version release, e.g. v1.0.0. that would be in a bit far future, and until it the class-based API will remain while being deprecated. So in that sense, you don't have to refactor all the code as long as you will need to follow the major update.

TBH, technically, the function-based API is a wrapper of the class-based callback implementation, so there is no big difference internally. I just want to deprecate the class-based one to reduce the support and maintenance cost.

I will be happy to contribute submitting a PR refrasing this part if you feel this disambiguation is needed :-)

Yes, definitely, Huge thanks to you :)

whitphx avatar Oct 20 '22 06:10 whitphx

Make sense, and keeping the class-based API as deprecated may be a good idea just because a lot of blog posts or even school graduation tests use it this way !

Thanx for your quick response, it's always appreciated when one is in a hurry :-)

I will keep this issue open to remind me to make a PR next week : got a too much disturbed busy day today. Romain

Rom1deTroyes avatar Oct 20 '22 12:10 Rom1deTroyes