Skip to content

Commit

Permalink
doc: improved migration doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pozil committed Oct 20, 2024
1 parent e368d6e commit 29e86be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See the [official Pub/Sub API repo](https://github.com/developerforce/pub-sub-ap

In v4 and earlier versions of this client:

- you had to specify configuration in a `.env` file with specific property names.
- you specify the configuration in a `.env` file with specific property names.
- you connect with either the `connect()` or `connectWithAuth()` method depending on the authentication flow.

In v5:
Expand All @@ -47,9 +47,30 @@ In v5:

### Event handling

In v4 and earlier versions of this client you used an asynchronous `EventEmitter` to receive updates such as incoming messages or lifecycle events.
In v4 and earlier versions of this client you use an asynchronous `EventEmitter` to receive updates such as incoming messages or lifecycle events:

In v5, you use a synchronous callback function to receive the same information. This helps to ensure that events are received in the right order.
```js
// Subscribe to account change events
const eventEmitter = await client.subscribe(
'/data/AccountChangeEvent'
);

// Handle incoming events
eventEmitter.on('data', (event) => {
// Event handling logic goes here
}):
```

In v5 you use a synchronous callback function to receive the same information. This helps to ensure that events are received in the right order.

```js
const subscribeCallback = (subscription, callbackType, data) => {
// Event handling logic goes here
};

// Subscribe to account change events
await client.subscribe('/data/AccountChangeEvent', subscribeCallback);
```

## Installation and Configuration

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"typescript": "^5.6.3"
},
"lint-staged": {
"**/{src,spec}/**/*.{css,html,js,json,md,yaml,yml}": [
"**/*.{css,html,js,json,md,yaml,yml}": [
"prettier --write"
],
"**/{src,spec}/**/*.js": [
Expand Down

0 comments on commit 29e86be

Please sign in to comment.