One thing that can help is to learn to identify particular warning signs and behaviors.
Depending on the dog, grabbing a weapon and brandishing it could turn a warning into an attack. With a different dog it could scare them away. Learning how to read the body signals can help prevent an attack.
Usually, a firm but calm tone and standing still can prevent an attack. But knowing what type of aggression should be responded to by direct eye contact or avoiding eye contact will be the difference between an attack or not.