Skip to content

Commit

Permalink
fix: Allow RxAjax to be called without any args
Browse files Browse the repository at this point in the history
  • Loading branch information
Alorel committed Sep 28, 2020
1 parent 16b73a2 commit e4a2814
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion projects/core/lib/rxAjax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ type Props = 'delete' | 'get' | 'getJSON' | 'patch' | 'post' | 'put' | 'extend';

/** Create an rxjs.ajax wrapper with the given default options */
export function rxAjax<BaseT = any>(defaults: RxAjaxOptions = {}): RxAjax<BaseT> {
function rxAjaxExecutor<T = BaseT>(urlOrRequest: string | RxAjaxOptions): Observable<RxAjaxResponse<T>> {
function rxAjaxExecutor<T = BaseT>(urlOrRequest?: string | RxAjaxOptions): Observable<RxAjaxResponse<T>> {
if (!urlOrRequest) {
return innerExecutor(defaults);
}

const mergeableOptions: RxAjaxOptions = typeof urlOrRequest === 'string' ? {url: urlOrRequest} : urlOrRequest;

return innerExecutor(merge(defaults, mergeableOptions));
Expand Down
3 changes: 2 additions & 1 deletion projects/core/types/RxAjax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export interface RxAjax<BaseT = any> {
/** Make a PUT request */
put<T = BaseT>(url: string, body: any, opts?: RxAjaxBodiedRequestOptions): Observable<RxAjaxResponse<T>>;

/** Generic request function */<T = BaseT>(urlOrRequest: string | RxAjaxOptions): Observable<RxAjaxResponse<T>>;
/** Generic request function */
<T = BaseT>(urlOrRequest?: string | RxAjaxOptions): Observable<RxAjaxResponse<T>>;
}

0 comments on commit e4a2814

Please sign in to comment.