Skip to content

Commit

Permalink
docs(retry): Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
masoud-msk committed Aug 29, 2024
1 parent 1101a3c commit c69a80b
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1660,10 +1660,10 @@
delaysArray?: number[];
retries?: number;
delay: number;
onRetry?: OnRetry;
onRetry?: OnRetry | string;
}

export type OnRetry = (error: Error, retriesCount: number) => void | string;
export type OnRetry = (error: Error, retriesCount: number) => void;
</pre>
</div>
</div>
Expand All @@ -1680,7 +1680,7 @@
constructor(private readonly dataProvider: DataProvider) { }

@retry(3)
getData: number): DataDto {
getData(): DataDto {
return this.dataProvider.getData();
}
}</pre>
Expand All @@ -1689,10 +1689,10 @@
<div class="ud-code-part">
<div class="ud-subtitle">Function Example 1:</div>
<pre class="ud-code">
import { retrify } from 'utils-decorators';
import { retryfy } from 'utils-decorators';
import { getData } from './data-provider';

const debouncedFoo = retrify(getData, 3);</pre>
const retriedGetData = retryfy(getData, 3);</pre>
</div>
</div>

Expand All @@ -1708,7 +1708,7 @@
constructor(private readonly dataProvider: DataProvider) { }

@retry([1000, 2000, 3000])
getData: number): DataDto {
getData(): DataDto {
return this.dataProvider.getData();
}
}</pre>
Expand All @@ -1717,10 +1717,10 @@
<div class="ud-code-part">
<div class="ud-subtitle">Function Example 2 (with delays array):</div>
<pre class="ud-code">
import { retrify } from 'utils-decorators';
import { retryfy } from 'utils-decorators';
import { getData } from './data-provider';

const debouncedFoo = retrify(getData, [1000, 2000, 3000]);</pre>
const retriedGetData = retryfy(getData, [1000, 2000, 3000]);</pre>
</div>
</div>

Expand All @@ -1738,28 +1738,37 @@
@retry({
retries: 3,
delay: 1500,
onError: (e, retriesCount) => console.log(e, retriesCount),
onRetry: (e, retriesCount) => console.log(e, retriesCount),
})
getData(): DataDto {
return this.dataProvider.getData();
}

@retry({
retries: 3,
delay: 1500,
onRetry: 'onRetry',
})
getData: number): DataDto {
getData2(): DataDto {
return this.dataProvider.getData();
}

onRetry(e: Error, retriesCount: number) {
console.log(e, retriesCount)
console.log(e, retriesCount);
}
}</pre>
</div>

<div class="ud-code-part">
<div class="ud-subtitle">Function Example 3 (with configuration object):</div>
<pre class="ud-code">
import { retrify } from 'utils-decorators';
import { retryfy } from 'utils-decorators';
import { getData } from './data-provider';

const debouncedFoo = retrify(getData, {
const retriedGetData = retryfy(getData, {
retries: 3,
delay: 1500,
onError: (e, retriesCount) => console.log(e, retriesCount),
onRetry: (e, retriesCount) => console.log(e, retriesCount),
});</pre>
</div>
</div>
Expand Down

0 comments on commit c69a80b

Please sign in to comment.