Skip to content

Commit 0d447e0

Browse files
committed
Update LiveObjects examples to use new npm workspace implementations
1 parent 5a5c1df commit 0d447e0

File tree

12 files changed

+27
-45
lines changed

12 files changed

+27
-45
lines changed

examples/liveobjects-live-counter/javascript/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ LiveCounters are implemented using [Ably LiveObjects](https://ably.com/docs/live
1212

1313
Use the following methods to interact with a LiveCounter in your application:
1414

15-
* [`objects.getRoot()`](https://ably.com/docs/liveobjects) - retrieves the root object that serves as the starting point for storing and organizing objects on a channel.
16-
* [`objects.createCounter()`](https://ably.com/docs/liveobjects) - creates a new LiveCounter instance.
17-
* [`liveCounter.value()`](https://ably.com/docs/liveobjects/livecounter) - returns the current value of a counter.
18-
* [`liveCounter.increment()`](https://ably.com/docs/liveobjects/livecounter) - sends the operation message to the Ably system to increase the counter value.
19-
* [`liveCounter.decrement()`](https://ably.com/docs/liveobjects/livecounter) - sends the operation message to the Ably system to decrease the counter value.
20-
* [`liveCounter.subscribe()`](https://ably.com/docs/liveobjects/livecounter) - subscribes to LiveCounter updates by registering a listener.
15+
- [`objects.getRoot()`](https://ably.com/docs/liveobjects) - retrieves the root object that serves as the starting point for storing and organizing objects on a channel.
16+
- [`objects.createCounter()`](https://ably.com/docs/liveobjects) - creates a new LiveCounter instance.
17+
- [`liveCounter.value()`](https://ably.com/docs/liveobjects/livecounter) - returns the current value of a counter.
18+
- [`liveCounter.increment()`](https://ably.com/docs/liveobjects/livecounter) - sends the operation message to the Ably system to increase the counter value.
19+
- [`liveCounter.decrement()`](https://ably.com/docs/liveobjects/livecounter) - sends the operation message to the Ably system to decrease the counter value.
20+
- [`liveCounter.subscribe()`](https://ably.com/docs/liveobjects/livecounter) - subscribes to LiveCounter updates by registering a listener.
2121

2222
Find out more about [LiveCounter](https://ably.com/docs/liveobjects/livecounter).
2323

@@ -41,7 +41,7 @@ cd /examples/
4141
mv .env.example .env.local
4242
```
4343

44-
4. In `.env.local` update the value of `VITE_PUBLIC_ABLY_KEY` to be your Ably API key.
44+
4. In `.env.local` update the value of `VITE_ABLY_KEY` to be your Ably API key.
4545

4646
5. Install dependencies:
4747

@@ -59,4 +59,4 @@ yarn run liveobjects-live-counter-javascript
5959

6060
## Open in CodeSandbox
6161

62-
In CodeSandbox, rename the `.env.example` file to `.env.local` and update the value of your `VITE_PUBLIC_ABLY_KEY` variable to use your Ably API key.
62+
In CodeSandbox, rename the `.env.example` file to `.env.local` and update the value of your `VITE_ABLY_KEY` variable to use your Ably API key.

examples/liveobjects-live-counter/javascript/postcss.config.ts

-7
This file was deleted.

examples/liveobjects-live-counter/javascript/src/script.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ export enum Color {
1111

1212
const client = new Realtime({
1313
clientId: nanoid(),
14-
key: import.meta.env.VITE_PUBLIC_ABLY_KEY as string,
14+
key: import.meta.env.VITE_ABLY_KEY as string,
1515
environment: 'sandbox',
1616
plugins: { Objects },
1717
});
1818

1919
const urlParams = new URLSearchParams(window.location.search);
2020

2121
const channelName = urlParams.get('name') || 'objects-live-counter';
22-
const channel = client.channels.get(channelName, { modes: ['STATE_PUBLISH', 'STATE_SUBSCRIBE'] });
22+
const channel = client.channels.get(channelName, { modes: ['OBJECT_PUBLISH', 'OBJECT_SUBSCRIBE'] });
2323

2424
const colorCountDivs: Record<Color, HTMLElement> = {
2525
red: document.getElementById('count-red'),

examples/liveobjects-live-counter/javascript/tailwind.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Config } from 'tailwindcss';
33

44
const config: Config = {
55
...baseConfig,
6+
content: ['./src/**/*.{js,ts,tsx}', './index.html'],
67
};
78

89
export default config;

examples/liveobjects-live-counter/javascript/vite-env.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
interface ImportMetaEnv {
2-
readonly VITE_PUBLIC_ABLY_KEY: string;
2+
readonly VITE_ABLY_KEY: string;
33
// Add other environment variables here if needed
44
}
55

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import baseConfig from '../../vite.config';
21
import { defineConfig } from 'vite';
3-
import dotenv from 'dotenv';
4-
import path from 'path';
5-
6-
dotenv.config({ path: path.resolve(__dirname, '../../.env.local') });
2+
import baseConfig from '../../vite.config';
73

84
export default defineConfig({
95
...baseConfig,
6+
envDir: '../../',
107
});

examples/liveobjects-live-map/javascript/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ LiveMaps are implemented using [Ably LiveObjects](https://ably.com/docs/liveobje
1212

1313
Use the following methods to interact with a LiveMap in your application:
1414

15-
* [`objects.getRoot()`](https://ably.com/docs/liveobjects) - retrieves the root object that serves as the starting point for storing and organizing objects on a channel.
16-
* [`objects.createMap()`](https://ably.com/docs/liveobjects) - creates a new LiveMap instance.
17-
* [`liveMap.get(key)`](https://ably.com/docs/liveobjects/livemap) - returns the current value associated with a given key in the map.
18-
* [`liveMap.set(key, value)`](https://ably.com/docs/liveobjects/livemap) - sends the operation message to the Ably system to assign a value to a key in the map.
19-
* [`liveMap.remove(key)`](https://ably.com/docs/liveobjects/livemap) - sends the operation message to the Ably system to remove a key from the map.
20-
* [`liveMap.subscribe()`](https://ably.com/docs/liveobjects/livemap) - subscribes to LiveMap updates by registering a listener.
15+
- [`objects.getRoot()`](https://ably.com/docs/liveobjects) - retrieves the root object that serves as the starting point for storing and organizing objects on a channel.
16+
- [`objects.createMap()`](https://ably.com/docs/liveobjects) - creates a new LiveMap instance.
17+
- [`liveMap.get(key)`](https://ably.com/docs/liveobjects/livemap) - returns the current value associated with a given key in the map.
18+
- [`liveMap.set(key, value)`](https://ably.com/docs/liveobjects/livemap) - sends the operation message to the Ably system to assign a value to a key in the map.
19+
- [`liveMap.remove(key)`](https://ably.com/docs/liveobjects/livemap) - sends the operation message to the Ably system to remove a key from the map.
20+
- [`liveMap.subscribe()`](https://ably.com/docs/liveobjects/livemap) - subscribes to LiveMap updates by registering a listener.
2121

2222
Find out more about [LiveMap](https://ably.com/docs/liveobjects/livemap).
2323

@@ -41,7 +41,7 @@ cd /examples/
4141
mv .env.example .env.local
4242
```
4343

44-
4. In `.env.local` update the value of `VITE_PUBLIC_ABLY_KEY` to be your Ably API key.
44+
4. In `.env.local` update the value of `VITE_ABLY_KEY` to be your Ably API key.
4545

4646
5. Install dependencies:
4747

@@ -59,4 +59,4 @@ yarn run liveobjects-live-map-javascript
5959

6060
## Open in CodeSandbox
6161

62-
In CodeSandbox, rename the `.env.example` file to `.env.local` and update the value of your `VITE_PUBLIC_ABLY_KEY` variable to use your Ably API key.
62+
In CodeSandbox, rename the `.env.example` file to `.env.local` and update the value of your `VITE_ABLY_KEY` variable to use your Ably API key.

examples/liveobjects-live-map/javascript/postcss.config.ts

-7
This file was deleted.

examples/liveobjects-live-map/javascript/src/script.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import './styles.css';
66

77
const client = new Realtime({
88
clientId: nanoid(),
9-
key: import.meta.env.VITE_PUBLIC_ABLY_KEY as string,
9+
key: import.meta.env.VITE_ABLY_KEY as string,
1010
environment: 'sandbox',
1111
plugins: { Objects },
1212
});

examples/liveobjects-live-map/javascript/tailwind.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Config } from 'tailwindcss';
33

44
const config: Config = {
55
...baseConfig,
6+
content: ['./src/**/*.{js,ts,tsx}', './index.html'],
67
};
78

89
export default config;

examples/liveobjects-live-map/javascript/vite-env.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
interface ImportMetaEnv {
2-
readonly VITE_PUBLIC_ABLY_KEY: string;
2+
readonly VITE_ABLY_KEY: string;
33
// Add other environment variables here if needed
44
}
55

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import baseConfig from '../../vite.config';
21
import { defineConfig } from 'vite';
3-
import dotenv from 'dotenv';
4-
import path from 'path';
5-
6-
dotenv.config({ path: path.resolve(__dirname, '../../.env.local') });
2+
import baseConfig from '../../vite.config';
73

84
export default defineConfig({
95
...baseConfig,
6+
envDir: '../../',
107
});

0 commit comments

Comments
 (0)