Skip to content

Commit ad26f41

Browse files
author
Pasquale Latrofa
committed
Move how to close server connection to old sdks
1 parent 1827b35 commit ad26f41

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/_index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ For an explanation on this topic, see [How to Manipulate Existing Models](/apido
4848
Some more explanation on manipulating existing models can be found in these documents:
4949

5050
* [How to Change Things in the Model](/apidocs-mxsdk/mxsdk/changing-things-in-the-model/)
51-
* [How to Close the Server Connection](/apidocs-mxsdk/mxsdk/closing-the-server-connection/)
5251
* [How to Find Things in the Model](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/)
5352
* [How to Load Units and Elements](/apidocs-mxsdk/mxsdk/loading-units-and-elements/)
5453

content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/changing-things-in-the-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ All the parts of a *deleted* element are also *deleted* and cannot be accessed.
106106

107107
## Next Step
108108

109-
Continue with [How to Close the Server Connection](/apidocs-mxsdk/mxsdk/closing-the-server-connection/).
109+
Continue with [How to Find Things in the Model](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/).

content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ The following how-tos present details for Mendix Platform SDK versions below 5.0
1313

1414
* [Set Up Your Development Environment (Old Versions)](/apidocs-mxsdk/mxsdk/old-setting-up-your-development-environment/)
1515
* [Create Your First Script (Old Versions)](/apidocs-mxsdk/mxsdk/old-creating-your-first-script/)
16+
* [How to Close the Server Connection (Old Versions)](/apidocs-mxsdk/mxsdk/old-closing-the-server-connection/)

content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md renamed to content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/old-closing-the-server-connection.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
---
22
title: "Close the Server Connection"
3-
url: /apidocs-mxsdk/mxsdk/closing-the-server-connection/
3+
url: /apidocs-mxsdk/mxsdk/old-closing-the-server-connection/
44
---
55

66
The SDK observes the complete model using the [mobx](https://github.com/mobxjs/mobx) library. This means that any change you make to the model is immediately synced with the working copy on the server. Sending changes to the server happens in the background and automatically, so there is no explicit commit. However, sending changes might take a while and your script should not end before all changes are flushed. In particular, changes are by default sent in batches of 1000 or after 200ms, whichever happens first. To wait until all changes are submitted to the server, use the [`closeConnection`](https://apidocs.rnd.mendix.com/modelsdk/latest/classes/model.html#closeconnection) function of the `model` object.
77

8-
This example shows the function `closeConnection`, which you can invoke when working with a `model` instance as a last step before the final commit:
8+
This example shows the function `closeConnection`, which you can invoke when working with a `workingCopy` instance as a last step before the final commit:
99

1010
```ts
11-
async function closeConnection(model: IModel): Promise<void> {
12-
return model
13-
.closeConnection()
14-
.then(() => {
15-
console.log(`Closed connection to Model API successfully.`);
16-
})
17-
.catch((err) => {
18-
console.error(`Failed to closed connection to Model API. Error: ${err}`);
11+
async function closeConnection(workingCopy: OnlineWorkingCopy) {
12+
await new Promise<void>((resolve, reject) => {
13+
workingCopy.model().closeConnection(
14+
() => {
15+
console.log(`Closed connection to Model API successfully.`);
16+
resolve();
17+
},
18+
(err) => {
19+
console.error(`Failed to closed connection to Model API. Error: ${err}`);
20+
reject();
21+
}
22+
);
1923
});
2024
}
21-
2225
```
2326

2427
Continue with [How to Find Things in the Model](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/).

0 commit comments

Comments
 (0)