|
| 1 | +[andculturecode-javascript-core](../README.md) › [DoSync](dosync.md) |
| 2 | + |
| 3 | +# Class: DoSync <**TResourceType, TReturnVal**> |
| 4 | + |
| 5 | +## Type parameters |
| 6 | + |
| 7 | +▪ **TResourceType** |
| 8 | + |
| 9 | +▪ **TReturnVal** |
| 10 | + |
| 11 | +## Hierarchy |
| 12 | + |
| 13 | +* **DoSync** |
| 14 | + |
| 15 | +## Index |
| 16 | + |
| 17 | +### Constructors |
| 18 | + |
| 19 | +* [constructor](dosync.md#private-constructor) |
| 20 | + |
| 21 | +### Properties |
| 22 | + |
| 23 | +* [catchHandler](dosync.md#private-optional-catchhandler) |
| 24 | +* [finallyHandler](dosync.md#private-optional-finallyhandler) |
| 25 | +* [workload](dosync.md#private-readonly-workload) |
| 26 | + |
| 27 | +### Methods |
| 28 | + |
| 29 | +* [catch](dosync.md#catch) |
| 30 | +* [execute](dosync.md#execute) |
| 31 | +* [finally](dosync.md#finally) |
| 32 | +* [try](dosync.md#static-try) |
| 33 | + |
| 34 | +## Constructors |
| 35 | + |
| 36 | +### `Private` constructor |
| 37 | + |
| 38 | +\+ **new DoSync**(`workload`: [SyncWorkload](../README.md#syncworkload)‹TReturnVal›): *[DoSync](dosync.md)* |
| 39 | + |
| 40 | +*Defined in [src/utilities/do-try.ts:97](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L97)* |
| 41 | + |
| 42 | +**Parameters:** |
| 43 | + |
| 44 | +Name | Type | |
| 45 | +------ | ------ | |
| 46 | +`workload` | [SyncWorkload](../README.md#syncworkload)‹TReturnVal› | |
| 47 | + |
| 48 | +**Returns:** *[DoSync](dosync.md)* |
| 49 | + |
| 50 | +## Properties |
| 51 | + |
| 52 | +### `Private` `Optional` catchHandler |
| 53 | + |
| 54 | +• **catchHandler**? : *undefined | function* |
| 55 | + |
| 56 | +*Defined in [src/utilities/do-try.ts:96](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L96)* |
| 57 | + |
| 58 | +___ |
| 59 | + |
| 60 | +### `Private` `Optional` finallyHandler |
| 61 | + |
| 62 | +• **finallyHandler**? : *[FinallyHandler](../README.md#finallyhandler)* |
| 63 | + |
| 64 | +*Defined in [src/utilities/do-try.ts:97](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L97)* |
| 65 | + |
| 66 | +___ |
| 67 | + |
| 68 | +### `Private` `Readonly` workload |
| 69 | + |
| 70 | +• **workload**: *[SyncWorkload](../README.md#syncworkload)‹TReturnVal›* |
| 71 | + |
| 72 | +*Defined in [src/utilities/do-try.ts:95](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L95)* |
| 73 | + |
| 74 | +## Methods |
| 75 | + |
| 76 | +### catch |
| 77 | + |
| 78 | +▸ **catch**(`errorHandler`: [CatchHandler](../README.md#catchhandler)‹TResourceType›): *[DoSync](dosync.md)‹TResourceType, TReturnVal›* |
| 79 | + |
| 80 | +*Defined in [src/utilities/do-try.ts:111](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L111)* |
| 81 | + |
| 82 | +Add a catch handler to the DoSync call chain. |
| 83 | +If errors are in the shape of a {ResultRecord}, |
| 84 | +you will get a typed {ResultRecord} as the first parameter. |
| 85 | +Otherwise, if it's an unknown error or Javascript error, |
| 86 | +you'll get an {any} as the second parameter. |
| 87 | + |
| 88 | +**Parameters:** |
| 89 | + |
| 90 | +Name | Type | Description | |
| 91 | +------ | ------ | ------ | |
| 92 | +`errorHandler` | [CatchHandler](../README.md#catchhandler)‹TResourceType› | handle errors, either as a {ResultRecord} or {any} | |
| 93 | + |
| 94 | +**Returns:** *[DoSync](dosync.md)‹TResourceType, TReturnVal›* |
| 95 | + |
| 96 | +___ |
| 97 | + |
| 98 | +### execute |
| 99 | + |
| 100 | +▸ **execute**(): *TReturnVal | undefined* |
| 101 | + |
| 102 | +*Defined in [src/utilities/do-try.ts:131](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L131)* |
| 103 | + |
| 104 | +Execute the entire DoSync call chain. For the synchronous version, i.e. DoSync, |
| 105 | +you must manually call .execute() for the call chain to be executed. |
| 106 | + |
| 107 | +**Returns:** *TReturnVal | undefined* |
| 108 | + |
| 109 | +TReturnVal the value returned from the workload, or undefined if an error occurred. |
| 110 | + |
| 111 | +___ |
| 112 | + |
| 113 | +### finally |
| 114 | + |
| 115 | +▸ **finally**(`finallyHandler`: [FinallyHandler](../README.md#finallyhandler)): *[DoSync](dosync.md)‹TResourceType, TReturnVal›* |
| 116 | + |
| 117 | +*Defined in [src/utilities/do-try.ts:147](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L147)* |
| 118 | + |
| 119 | +Run some handler when the function completes, whether the |
| 120 | +catch() was hit or not. |
| 121 | + |
| 122 | +**Parameters:** |
| 123 | + |
| 124 | +Name | Type | |
| 125 | +------ | ------ | |
| 126 | +`finallyHandler` | [FinallyHandler](../README.md#finallyhandler) | |
| 127 | + |
| 128 | +**Returns:** *[DoSync](dosync.md)‹TResourceType, TReturnVal›* |
| 129 | + |
| 130 | +this |
| 131 | + |
| 132 | +___ |
| 133 | + |
| 134 | +### `Static` try |
| 135 | + |
| 136 | +▸ **try**<**TResourceType**, **TReturnVal**>(`workload`: [SyncWorkload](../README.md#syncworkload)‹TReturnVal›): *[DoSync](dosync.md)‹TResourceType, TReturnVal›* |
| 137 | + |
| 138 | +*Defined in [src/utilities/do-try.ts:159](https://github.com/AndcultureCode/AndcultureCode.JavaScript.Core/blob/ba68f27/src/utilities/do-try.ts#L159)* |
| 139 | + |
| 140 | +Static factory method for DoSync. Creates a new DoSync |
| 141 | +with the given workload. |
| 142 | + |
| 143 | +**Type parameters:** |
| 144 | + |
| 145 | +▪ **TResourceType** |
| 146 | + |
| 147 | +▪ **TReturnVal** |
| 148 | + |
| 149 | +**Parameters:** |
| 150 | + |
| 151 | +Name | Type | Description | |
| 152 | +------ | ------ | ------ | |
| 153 | +`workload` | [SyncWorkload](../README.md#syncworkload)‹TReturnVal› | | |
| 154 | + |
| 155 | +**Returns:** *[DoSync](dosync.md)‹TResourceType, TReturnVal›* |
0 commit comments