In this talk, we study AC microgrid dynamics with included primary and distributed secondary frequency controllers using time-varying communication networks with (i) bidirectional, and (ii) unidirectional communication links. For a certain class of controllers, the closed-loop dynamics solve a special multi-agent optimization problem by performing two steps: (i) gradient-descent, and (ii) distributed averaging – averaging with neighbors. This proposed framework allows the analysis of many of the existing distributed algorithms developed to solve a general multi-agent optimization problem over time-varying communication networks; including those that use the so-called subgradient-push algorithm to design a distributed frequency controller. We present the convergence analysis for the closed-loop system. In addition, we deploy this framework to propose a distributed frequency controller that does not require each agent (generator) to know its so-called out-degree – a necessary assumption for the convergence of the subgradient-push algorithm.