@base44-preview/sdk 0.8.49-pr.289.cceffb2 → 0.8.49-pr.289.e36026d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/actors.types.d.ts +17 -25
- package/package.json +1 -1
|
@@ -140,43 +140,35 @@ export interface ActorClient<N extends string = string> {
|
|
|
140
140
|
(instanceId: string): ActorRef<N>;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* Use `base44.actors` to connect your frontend to [actor sessions](/developers/backend/resources/actors/overview),
|
|
144
|
+
* shared live backend processes where clients can exchange messages in realtime.
|
|
144
145
|
*
|
|
145
|
-
*
|
|
146
|
-
* client lets you:
|
|
146
|
+
* With the Actors SDK module you can:
|
|
147
147
|
*
|
|
148
|
-
* -
|
|
149
|
-
*
|
|
150
|
-
*
|
|
148
|
+
* - Connect to a session with `base44.actors.<ActorName>(sessionId).connect()`.
|
|
149
|
+
* - Subscribe to messages the actor sends using [Connection.subscribe](#subscribe),
|
|
150
|
+
* either broadcast to all clients or sent directly to your client.
|
|
151
|
+
* - Send messages to the actor with [Connection.send](#send).
|
|
151
152
|
* - Share a session across multiple clients: any clients with the same actor
|
|
152
153
|
* name and session ID connect to the same session.
|
|
153
154
|
* - Type your messages using [ActorRegistry](#actorregistry) for autocomplete
|
|
154
155
|
* and compile-time safety.
|
|
155
156
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* ## Connection flow
|
|
159
|
-
*
|
|
160
|
-
* - Connect to a session with `base44.actors.<ActorName>(sessionId).connect()`.
|
|
161
|
-
* - Subscribe to outgoing messages with [Connection.subscribe](#subscribe).
|
|
162
|
-
* - Send incoming messages with [Connection.send](#send).
|
|
163
|
-
* - Close the connection with [Connection.close](#close).
|
|
164
|
-
*
|
|
165
|
-
* See [Actors Overview](/developers/backend/resources/actors/overview)
|
|
166
|
-
* for actor concepts and terminology, [Actor Class Reference](/developers/backend/resources/actors/reference)
|
|
167
|
-
* for the backend class API, and [Sample Flows](/developers/backend/resources/actors/samples)
|
|
168
|
-
* for common patterns.
|
|
157
|
+
* Learn more about [actors](/developers/backend/resources/actors/overview).
|
|
169
158
|
*
|
|
170
159
|
* ## Authentication modes
|
|
171
160
|
*
|
|
172
|
-
* This module is available in anonymous or user authentication mode
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
*
|
|
161
|
+
* This module is available in anonymous or user authentication mode.
|
|
162
|
+
* Apps that require login can reject anonymous connections in the actor's `handleConnect()` method.
|
|
163
|
+
* Learn more about [managing client connections](/developers/backend/resources/actors/samples#manage-client-connections).
|
|
164
|
+
|
|
165
|
+
|
|
178
166
|
* @example
|
|
167
|
+
*
|
|
168
|
+
* The following example displays the general lifecycle of a client connected to an actor named `Chat`:
|
|
169
|
+
*
|
|
179
170
|
* ```typescript
|
|
171
|
+
* Example
|
|
180
172
|
* const conn = base44.actors.Chat("session-1").connect({ id: "tab-1" });
|
|
181
173
|
* const sub = conn.subscribe((msg) => console.log(msg));
|
|
182
174
|
* conn.send({ type: "message", text: "hi" });
|