anchor.diff:           terminate/2,
            code_change/3]).
   
  --record(state, { callback }).
  +-record(state, {callback}).
   
   %% ===================================================================
   %% API functions
  
positive.code: add_sup_callback(Fn) when is_function(Fn) ->
      gen_event:add_sup_handler(?MODULE, {?MODULE, make_ref()}, [Fn]).
  
  update(LocalState) ->
      gen_event:notify(?MODULE, {update, LocalState}).
  
  %% ===================================================================
  %% gen_event callbacks
  
negative.code: 
  init([Fn]) ->
      {ok, LocalState} = ?PEER_SERVICE_MANAGER:get_local_state(),
      try
          Fn(LocalState)
      catch
          _:Error ->
              lager:error("Error with callback: ~p", [Error])
      end,
      {ok, #state{callback=Fn}}.
  
  handle_event({update, LocalState}, State) ->
      (State#state.callback)(LocalState),
      {ok, State};
  handle_event(Event, State) ->
      lager:info("Unhandled event: ~p", [Event]),
      {ok, State}.
  
  handle_call(Request, State) ->
      lager:info("Unhandled message: ~p", [Request]),
      {ok, ok, State}.
  
  handle_info(Info, State) ->
      lager:info("Unhandled message: ~p", [Info]),
      {ok, State}.
  
  terminate(_Reason, _State) ->
  