Outback, Magnum and Schneider all have inverter / chargers. There are other brands as well, but those are the Big 3 that are used in serious off grid residential installations. When we had a large Class C RV we ran an Outback unit like
thiswhich is the same unit we run in our off grid cabin.
Think of it as two devices in the same box. The inverter section uses DC battery power to output 120 VAC (other voltages available for export versions).
The charger section uses 120 VAC input from an outside source, such as a generator or a connection to the power grid. It outputs DC at a voltage suitable for the batteries. Our system @ the cabin is 24 VDC.
Simply put, when the inverter / charger senses input 120 VAC power (let's say from a generator) it switches on the charger section and simultaneously turns the inverter section off. Inside the unit is a relay system that actually connects the charger to the battery at the same time it disconnects the battery input to the inverter section. So the AC incoming is passed through the "box" and out the 120 VAC outputs while diverting whatever 120 VAC is needed to operate the charger section. The switching happens fast enough to not even cause a hiccup with any electronics we have.
A unit like the Outback are very user friendly. They have three circuit boards that are user swapable. If we had not had a direct lightning strike the original would still be in service. As it is I replaced the boards and it runs.