# For Example: reference methods \[Listen\] and \[PubSub\] (send Extension PubSub message)

**URL:** <https://discuss.dev.twitch.com/t/for-example-reference-methods-listen-and-pubsub-send-extension-pubsub-message/28436>\
**Category:** Extensions\
**Created:** [October 3, 2020, 2:26pm UTC](https://discuss.dev.twitch.com/t/for-example-reference-methods-listen-and-pubsub-send-extension-pubsub-message/28436 "2020-10-03T14:26:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robot](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@Robot](https://discuss.dev.twitch.com/u/Robot)\
**Post date:** [October 3, 2020, 2:26pm UTC](https://discuss.dev.twitch.com/t/for-example-reference-methods-listen-and-pubsub-send-extension-pubsub-message/28436/1 "2020-10-03T14:26:30Z")

</div>

Please tell where can find code examples of how to use the **Listen** function together with **PubSub**?  
(I’m sending a request like “_Example Request #1 (Channel)_” [[link](https://dev.twitch.tv/docs/extensions/reference/#send-extension-pubsub-message)] from my **EBS** and my extension using the **Listen** method should pick it up, but how exactly does that happen?)

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 3, 2020, 2:30pm UTC](https://discuss.dev.twitch.com/t/for-example-reference-methods-listen-and-pubsub-send-extension-pubsub-message/28436/2 "2020-10-03T14:30:02Z")

</div>

Here you go

> **[BarryCarlyon/twitch\_misc](https://github.com/BarryCarlyon/twitch_misc/tree/main/extensions/config_service)**
>
> main/extensions/config\_service

Specifically this example covers the config service and PubSub together

You save the config, then push the same config out over PubSub.

As config in the config object is only updated via `onChanged` ONCE per page load on first call of that function. So updates to config have to be sent to the frontend another way.

So to update config you need to use the pubsub service

> <https://github.com/BarryCarlyon/twitch_misc/blob/main/extensions/config_service/set_n_publish_frontend.js#L21>

Is how to listen in the front end (on global)

> <https://github.com/BarryCarlyon/twitch_misc/blob/main/extensions/config_service/set_n_publish.js#L101>

Is the actual send for the global topic, but refer to further up the file for the Authentication construction

---

<div class="post-metadata">

**Author:** ![Robot](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@Robot](https://discuss.dev.twitch.com/u/Robot)\
**Post date:** [October 3, 2020, 5:03pm UTC](https://discuss.dev.twitch.com/t/for-example-reference-methods-listen-and-pubsub-send-extension-pubsub-message/28436/3 "2020-10-03T17:03:26Z")

</div>

Thanks for the examples.  
Did I understand correctly that if, for example, I need to run a function in my interface, then I have to write its launch here?

_function configureExtension(the\_config) {_  
// do whatever you want with your config  
// (re)build the extension  
_}_

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [October 3, 2020, 5:04pm UTC](https://discuss.dev.twitch.com/t/for-example-reference-methods-listen-and-pubsub-send-extension-pubsub-message/28436/4 "2020-10-03T17:04:12Z")

</div>

You can either do that or do it directly inside `onChanged`

there is no right/wrong way
