  We present a compact \textit{in-situ} electromagnet with an active cooling
system for the use in ultra-high vacuum environments. The active cooling
enhances the thermal stability and increases the electric current that can be
applied through the coil, promoting the generation of homogeneous magnetic
fields, required for applications in real-time deposition experiments. The
electromagnet has been integrated into a reflectance difference magneto-optic
Kerr effect (RD-MOKE) spectroscopy system that allows the synchronous
measurement of the optical anisotropy and the magneto-optic response in polar
MOKE geometry. Proof of principle studies have been performed in real-time
during the deposition of ultra-thin Ni films on Cu(110)-(2$\times$1)O surfaces,
corroborating the extremely sharp spin reorientation transition above a
critical coverage of 9 monolayers and demonstrating the potential of the
applied setup for real-time and \textit{in-situ} investigations of magnetic
thin films and interfaces.
