edge/doc/apps/client-api/edge-client.md
William Petit b5b4042cc7
All checks were successful
arcad/edge/pipeline/head This commit looks good
feat(sdk,client): add menu to help navigation between apps
2023-04-20 10:17:37 +02:00

68 lines
1.1 KiB
Markdown

# `Edge.Client`
## Méthodes
### `Edge.Client.connect(): Promise`
> `TODO`
### `Edge.Client.disconnect(): void`
> `TODO`
### `Edge.Client.send(message: Object): void`
> `TODO`
### `Edge.Client.rpc(method: string, params: Object): Promise`
> `TODO`
#### Exemple
**Côté serveur**
```js
function onInit() {
rpc.register(echo);
}
function echo(ctx, params) {
return params;
}
```
**Côté client**
```js
Edge.Client.connect().then(() => {
Edge.Client.rpc("echo", { hello: "world!" })
.then(result => console.log(result))
.catch(err => console.error(err));
});
```
### `Edge.Client.upload(blob: Blob, metadata: Object): Promise`
> `TODO`
### `Edge.Client.blobUrl(bucketName: string, blobId: string): string`
> `TODO`
### `Edge.Client.externalUrl(url: string): string`
Retourne une URL "locale" permettant d'accéder à une ressource externe, en fonction de règles propres à l'application. Voir module [`fetch`](../server-api/fetch.md).
## Événements
### `"message"`
> `TODO`
#### Exemple
```js
Edge.Client.addEventListener("message", evt => console.log(evt.detail));
```