Skip to content

chore: update examples for new client #971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/examples/chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,7 @@ Add the form submit handler to your init function:
async function init() {
// Connect to chat room with channel tag
const chatRoom = await client.get({
name: 'chat-room',
channel, // Use channel as a tag to separate different chat rooms
});
const chatRoom = await client.chatRoom.getOrCreate(channel);
// Store reference for use in event handlers
// In a production app, you'd use a more encapsulated approach
Expand Down
2 changes: 1 addition & 1 deletion examples/chat-room/scripts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function main() {

// connect to chat room - now accessed via property
// can still pass parameters like room
const chatRoom = client.chatRoom.get(room, {
const chatRoom = client.chatRoom.getOrCreate(room, {
params: { room },
}).connect();

Expand Down
2 changes: 1 addition & 1 deletion examples/chat-room/scripts/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function main() {
const client = createClient<App>(process.env.ENDPOINT ?? "http://localhost:6420");

// connect to chat room - now accessed via property
const chatRoom = client.chatRoom.get().connect();
const chatRoom = client.chatRoom.getOrCreate().connect();

// call action to get existing messages
const messages = await chatRoom.getHistory();
Expand Down
2 changes: 1 addition & 1 deletion examples/chat-room/tests/chat-room.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test("chat room should handle messages", async (test) => {
const { client } = await setupTest(test, app);

// Connect to chat room
const chatRoom = client.chatRoom.get().connect();
const chatRoom = client.chatRoom.getOrCreate().connect();

// Initial history should be empty
const initialMessages = await chatRoom.getHistory();
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/tests/counter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { app } from "../actors/app";

test("it should count", async (test) => {
const { client } = await setupTest(test, app);
const counter = client.counter.get().connect();
const counter = client.counter.getOrCreate().connect();

// Test initial count
expect(await counter.getCount()).toBe(0);
Expand Down
2 changes: 1 addition & 1 deletion examples/linear-coding-agent/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ server.post("/api/webhook/linear", async (c) => {
// Create or get a coding agent instance with the issue ID as a key
// This ensures each issue gets its own actor instance
console.log(`[SERVER] Getting actor for issue: ${issueId}`);
const actorClient = client.codingAgent.get(issueId).connect();
const actorClient = client.codingAgent.getOrCreate(issueId).connect();

// Initialize the agent if needed
console.log(`[SERVER] Initializing actor for issue: ${issueId}`);
Expand Down
2 changes: 1 addition & 1 deletion examples/resend-streaks/tests/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ beforeEach(() => {

test("streak tracking with time zone signups", async (t) => {
const { client } = await setupTest(t, app);
const actor = client.user.get().connect();
const actor = client.user.getOrCreate().connect();

// Sign up with specific time zone
const signupResult = await actor.completeSignUp(
Expand Down