# ChangeBroadcaster::addListener(Listener\*, lambda)

**URL:** <https://forum.juce.com/t/changebroadcaster-addlistener-listener-lambda/39325>\
**Category:** General JUCE discussion\
**Created:** [May 10, 2020, 8:26pm UTC](https://forum.juce.com/t/changebroadcaster-addlistener-listener-lambda/39325 "2020-05-10T20:26:34Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![yfede](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/yfede/32/506_2.png) [@yfede](https://forum.juce.com/u/yfede)\
**Post date:** [May 12, 2020, 9:02am UTC](https://forum.juce.com/t/changebroadcaster-addlistener-listener-lambda/39325/9 "2020-05-12T09:02:27Z")

</div>

> [@matkatmusic](#):
>
> I also had this initial idea:

Looks like an almost identical proposal was done some time ago:

> [@Scoped-Listeners / Modernize listeners](https://forum.juce.com/t/scoped-listeners-modernize-listeners/23742):
>
> I’ve made this little class, and it really revolutionised my programming style. Its a scoped listener, and very easily combines the listener (old-school) functionality with the ability to attach std::function lambdas to it (a more modern approach). It’s not a very sophisticated, its very plain and simple. Example: class TestComponent : public Component { public: TestComponent( ColourSelector\* selector, MidiKeyboardComponent\* keyboard ) { // attach updateUI to the ChangeBroadcaster of Col…

My thoughts about this: it would be really nice if it were possible, with some template magic, to do something like

`ScopedListener <ChangeListener> listener (broadcaster);`

`ScopedListener <Button::Listener> listener (button);`

etc.

---

_[View the full topic](https://forum.juce.com/t/changebroadcaster-addlistener-listener-lambda/39325)._
