How to declare a global variable in a custom plugin?

Hi everyone,

I’m developing a custom plugin that records audio, there are basically two actions in this plugin:

  • start recording
  • stop recording

I need to have global variable that will be used by my two functions (related to the two actions above). But I don"t get where I can declare global variables inside bubble. Maybe it has been designed to code functions in a different/specific way ?

Thanks in advance for your help,

Two options:

  1. Declare it as a Window variable: window.myVar = 1. That is accessible everywhere

  2. Pass local variables between functions by storing it in



I use this to pass data between elements.

You can event publish one elements custom state by firing off an event in a different element if you set window.instance = instance from the first element ,

then you can call

window.instance.publishState('") from the second element! this is a useful trick to get around circular data issues!


Hi @robhblake,

It works perfectly fine! Thanks!

1 Like

Thanks @jared.gibb good to know! I note it!