You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: daprdocs/content/en/js-sdk-docs/js-actors/_index.md
+83-82
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ To jump in and run this example yourself, clone the source code, which can be fo
26
26
## Actor Interface
27
27
The actor interface defines the contract that is shared between the actor implementation and the clients calling the actor. In the example below, we have created an interace for a parking garage sensor. Each sensor has 2 methods: `carEnter` and `carLeave`, which defines the state of the parking space:
28
28
29
-
```javascript
29
+
```ts
30
30
exportdefaultinterfaceParkingSensorInterface {
31
31
carEnter():Promise<void>;
32
32
carLeave():Promise<void>;
@@ -38,7 +38,7 @@ An actor implementation defines a class by extending the base type `AbstractActo
38
38
39
39
The following code describes an actor implementation along with a few helper methods.
After Actors are registered, use the `DaprClient` to invoke methods on an actor. The client will call the actor methods defined in the actor interface.
85
92
86
93
```javascript
87
-
import { DaprClient } from"dapr-client";
94
+
import { DaprClient, ActorId } from"dapr-client";
88
95
importParkingSensorImplfrom"./ParkingSensorImpl";
89
96
90
97
constdaprHost="127.0.0.1";
91
98
constdaprPort="50000";
92
99
93
100
constclient=newDaprClient(daprHost, daprPort);
94
101
95
-
awaitclient.actor.invoke("PUT", ParkingSensorImpl.name, `actor-id`, "carEnter"); // Invoke the ParkingSensor Actor by calling the carEnter function
96
-
}
102
+
// Create a new actor builder. It can be used to create multiple actors of a type.
The JS SDK supports actors that can schedule periodic work on themselves by registering either timers or reminders. The main difference between timers and reminders is that the Dapr actor runtime is not retaining any information about timers after deactivation, while persisting the information about reminders using the Dapr actor state provider.
138
+
The JS SDK supports actors that can schedule periodic work on themselves by registering either timers or reminders. The main difference between timers and reminders is that the Dapr actor runtime does not retain any information about timers after deactivation, but persists reminders information using the Dapr actor state provider.
140
139
141
-
This distintcion allows users to trade off between light-weight but stateless timers vs. more resource-demanding but stateful reminders.
140
+
This distinction allows users to trade off between light-weight but stateless timers versus more resource-demanding but stateful reminders.
142
141
143
142
The scheduling interface of timers and reminders is identical. For an more in-depth look at the scheduling configurations see the [actors timers and reminders docs]({{< ref "howto-actors.md#actor-timers-and-reminders" >}}).
To handle the callback, you need to override the default `receiveReminder` implementation in your actor. For example, from our original actor implementation:
0 commit comments