Hook into Replset Status/Configuration Changes

Is there a way to easily call a procedure/hook on Replset status changes (such a new member being elected Primary)?