Closed JonasVautherin closed 2 years ago
I agree it would be nice to be able to register multiple callbacks for the wrappers as well as for the C++ API. Now as you asked the question is how to unregister. I don't know what pattern or mechanism is suited for this.
I have the same challenge with various methods that are registered by the plugins against SystemImpl
. I use a "cookie" which is basically the this
pointer of the object registering something.
@JonasVautherin @julianoes Any updates on this? I also encountered this issue while using the Python wrapper, currently avoiding the problem by splitting my program into multiple scripts with separate MAVSDK connections ... this is not ideal :smile:
No update as far as I know, so it's still in the state described above. I would love it if an advanced python developer could give an opinion and help finishing it :+1:.
That will be fixed with MAVSDK v2.
Currently, at the C++ level, streams like
position_async()
register one unique callback. This means that one cannot register two callbacks: the second call will erase the previous one.I believe that this is not the behavior we want in Python. Already in Swift and Java, a stream is shared between the consumers at the language binding level (by using Rx mechanics).
I made a proof of concept for
position()
(thanks to Samyash for the help), essentially trying to call_stub.SubscribePosition(request)
only once and sharing that with all the consumers.I looks like below, exposing
position()
as before and instantiating the factory in a lazy way (only when the first consumer registers).Still to be investigated: