anchor.diff:      after 0 ->
           {updated, UserAcc}
       end.
  +
  +reset_heartbeat() ->
  +    put(last_changes_heartbeat,now()).
  +
  +maybe_heartbeat(Timeout, TimeoutFun, Acc) ->
  +    Now = now(),
  +    Before = get(last_changes_heartbeat),
  +    case Before of
  +    undefined ->
  +        {ok, Acc};
  +    _ ->
  +        case timer:now_diff(Now, Before) div 1000 >= Timeout of
  +        true ->
  +            Acc2 = TimeoutFun(Acc),
  +            put(last_changes_heartbeat, Now),
  +            Acc2;
  +        false ->
  +            {ok, Acc}
  +        end
  +    end.
  
positive.code:     resp_type,
      limit,
      include_docs,
      conflicts
  }).
  
  %% @type Req -> #httpd{} | {json_req, JsonObj()}
  
negative.code:         end_sending_changes(Callback, UserAcc2, EndSeq, ResponseType);
      true ->
          case wait_db_updated(Timeout, TimeoutFun, UserAcc2) of
          {updated, UserAcc4} ->
              DbOptions1 = [{user_ctx, Db#db.user_ctx} | DbOptions],
              case couch_db:open(Db#db.name, DbOptions1) of
              {ok, Db2} ->
                  keep_sending_changes(
                    Args#changes_args{limit=NewLimit},
                    ChangesAcc#changes_acc{
                      db = Db2,
                      user_acc = UserAcc4,
                      seq = EndSeq,
                      prepend = Prepend2,
                      timeout = Timeout,
                      timeout_fun = TimeoutFun},
                    false);
              _Else ->
                  end_sending_changes(Callback, UserAcc2, EndSeq, ResponseType)
              end;
          {stop, UserAcc4} ->
              end_sending_changes(Callback, UserAcc4, EndSeq, ResponseType)
          end
      end.
  
  