Well its something i was thinking yesterday.
I solved the problem already.
Here its what i did (could be useful for someone) (im using es6 and react):
1.- I set layer definitions for each sublayer on the Dynamic Service. (
var layerDefinitions = [];
layerDefinitions[0] = "COUNTRY = '"+ this.state.COUNTRY [0].queryName+"'";
layerDefinitions[1] = "COUNTRY = '"+ this.state.COUNTRY [0].queryName+"'";
2.- I set a variable per many sublayer i wanted to add to the map. In this case im going to show just 2, one with scale and one with the default scale (for seeing for afar). Also i set the layer defs for each one.
var carsLayer = new ArcGISDynamicMapServiceLayer(layers.read_dynamic_ap(),{ minScale: 6000});
carsLayer .setImageFormat("png32");
carsLayer .setVisibleLayers([0]);
carsLayer .setLayerDefinitions(layerDefinitions);
var streetsLayer = new ArcGISDynamicMapServiceLayer(layers.read_dynamic_ap(),{});
streetsLayer .setImageFormat("png32");
streetsLayer .setVisibleLayers([1]);
streetsLayer .setLayerDefinitions(layerDefinitions);
3.- I added them to the map in the secuence i want to show them (for example i want the streets goes first, so i put it at last)
mapp.addLayers([carsLayer , streetsLayer ]);
4.- Then how i wanna save the layers in some variable to use the show() and hide() method for the layerlist i made, i just keep them in dynamicService.
this.setState({dynamicService: [carsLayer, streetsLayer]})
Then , for my custom layerList i made, i just change the visibility doing :
this.state.dynamicService[0].show();
Thanks for all the help! I figure out how to solve my issue