Skip to content

Commit 18211c6

Browse files
author
Subramanian Alagappan
authored
Merge pull request #17 from FurhatRobotics/update-furhat-core_migrate-to-TS
Update furhat core migrate to ts
2 parents 0085f0b + 22d7b0a commit 18211c6

8 files changed

Lines changed: 14019 additions & 106 deletions

File tree

.eslintrc

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
{
2-
"parser": "babel-eslint",
3-
"extends": [
4-
"airbnb-base",
5-
"plugin:flowtype/recommended"
6-
],
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
74
"plugins": [
8-
"flowtype",
9-
"flowtype-errors"
5+
"@typescript-eslint"
106
],
11-
"env": {
12-
"jest": true
13-
},
14-
"rules": {
15-
"semi": [2, "never"],
16-
"comma-dangle": [2, "always-multiline"],
17-
"flowtype-errors/show-errors": 2
18-
}
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended"
11+
]
1912
}

README.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,33 @@ Client library for connecting to a Furhat skill from a skill GUI
1313
## Usage
1414

1515
```js
16-
import FurhatGUI from 'furhat-gui'
16+
import FurhatGUI, { Furhat } from 'furhat-gui'
1717

18-
FurhatGUI((furhat) => {
19-
furhat.send({
20-
event_name: 'MyEvent',
21-
param1: 'MyParam1'
22-
})
18+
let furhat: Furhat = null
2319

24-
furhat.subscribe('com.myapp.MyCustomeEvent', (event) => {
25-
console.log('recieved event: ', event.event_name)
20+
function setupSubscriptions () {
21+
furhat.subscribe('com.myapp.MyCustomEvent', (event) => {
22+
console.log('received event: ', event.event_name)
23+
})
24+
}
25+
26+
FurhatGUI()
27+
.then(connection => {
28+
furhat = connection
29+
furhat.onConnectionError((_connection: WebSocket, ev: globalThis.Event) => {
30+
console.error("Error occured while connecting to Furhat skill")
31+
})
32+
furhat.onConnectionClose(() => {
33+
console.warn("Connection with Furhat skill has been closed")
34+
})
35+
setupSubscriptions()
2636
})
37+
.catch(console.error)
38+
39+
// Later somewhere in the code (after awaiting for the connection promise)
40+
furhat.send({
41+
event_name: 'MyEvent',
42+
param1: 'MyParam1'
2743
})
2844
```
2945

@@ -40,8 +56,4 @@ FurhatGUI((furhat) => {
4056
FurhatGUI Function which sets up a connection to the furhat skill and gives
4157
the furhat object to send and recieve events to the skill.
4258

43-
**Parameters**
44-
45-
- `callback` callback that needs to be triggered when a sucessful connection is established
46-
47-
Returns **any** Promise that will return the promise of the connection
59+
Returns **any** Promise that will return the promise with a `Furhat` obkect

index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)