What is an `ObservableMixin` in the Autobahn project?

Hello there,

I’m going around the autobahn source code at github and was wondering what an [OberservableMixin](https://github.com/crossbario/autobahn-python/blob/71e1cbd24f19e6628d3d731985ca8434bce5f5ab/autobahn/util.py#L738) is in the project. I have an intermediate knowledge of twisted and some knowledge of how events are multiplexed in Twisted. However, there are classes and methods that I find in the source code of Autobahn that I can’t really comprehend and although these are not API related I really wish someone could give me a brief insight into it.
I’m supposing that these are advanced computer science concepts that I yet don’t understand. Can someone (or the developers itself) link me a book (or books) that have or provide some explanation to these abstract concepts? In any case I’m just curious… I want to know what the developers learned for them being able to write this type of code!

That class allows us to easily enabled “listener”-style things, such as ApplicationSession.on('open', ...). This is an internal helper for classes like ApplicationSession that puts the common code for “notify all the listeners” in one place.

More-recent Twisted code sometimes uses functions like on_some_event() which return Deferrreds; this is a somewhat similar concept, but with just a generic “callback” function instead of a Deferred (partially because we support Twisted AND asyncio from the same codebase, but also to mirror the interfaces/API of the JS and C++ codebases).

1 Like