move gen_event for service worker to a separate module