What's valuetree used for?

I search and can’t understand.
can i use it as a global datastruct.and main/sub component acesss it?
why not I just use std::map std::vector under mycontrol.
confuse but seems lots of people here use valuetree.

The ValueTree class solves multiple problems at once which are storing data, serialization & de-serialization to restore your application state, managing undo and redo actions and notify listeners like GUI widgets that reflect the state of the data. You can have e.g. multiple components that react to changes. Think of an EQ, you modify a parameter by a slider and immediately the DSP processing section updates it’s parameters so that you hear the changes, a graph visualizing the frequency response updates and maybe some numerical values on the GUI change.

Of course you can store the underlying data that describes the state into other more basic containers but they don’t supply you any means to register listeners, notify listeners and perform undo operarions.

This tutorial gives a short introduction https://docs.juce.com/master/tutorial_value_tree.html

This video gives a really great idea of what this means for real world applications:

need I use valueTree as a global vars and set to every sub components?

Not exactly sure if I get your question right. Maybe a short piece of (pseudo) code demonstrating your idea of value tree usage would clear things up a little bit?

As you mention globals, just a side note, generally speaking you want to avoid global variables in C++ if possible. It‘s a good idea to keep the root tree as a member of your application base class, but there is no one fits all answer

that’s ok
as my app would only 3layers and tensof dialogs ,its simple by only one main component and could do everything on main component.
seems its no useful right now on valuetree if I have broadcast and listener.

I just learn and understand more about valuetree. now I am seeking a threadsafe way to
talk with gui and threads. but vflib seems old and outdate.
do you have a suggest? thanks