It depends at which point you add salt in your food while you’re preparing it, also that’s not the best time for the other ingredients.
When you cook rice, pasta or meat, you need to add salt before you cook it, while on the other hand, when you’re cooking mushrooms or peas you should add salt after you cook it, and for onions it does not matter.
Here’s why the rice and the pasta are absorbing the salt water, while it’s cooking, and it becomes softer. The meat must be seasoned before cooking, because when you cook it, that’s when the meat absorbs the tastes and smells, therefore it will absorb the seasoning better if you do it before cooking it.
If you salt the peas before cooking, it will take a bit longer to cook, that’s why you should add the seasoning at the end. Mushrooms are rich in water, that’s why they should also be seasoned at the end, otherwise their juices come out, and they don’t have the best taste.
When it comes to the onions, if you want it a bit crunchy and golden, season it at the end, and if you want it to be softer, you must season it before cooking it, that way it will keep its bright color.