@@ -10,10 +10,6 @@ const serverHost = "127.0.0.1"; // App Host of this Example Server
10
10
const serverPort = "50001" ; // App Port of this Example Server
11
11
const daprAppId = "example-hello-world" ;
12
12
13
- async function sleep ( ms : number ) : Promise < void > {
14
- return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
15
- }
16
-
17
13
async function start ( ) {
18
14
const server = new DaprServer ( serverHost , serverPort , daprHost , daprPort ) ;
19
15
const client = new DaprClient ( daprHost , daprPort ) ;
@@ -39,43 +35,13 @@ async function start() {
39
35
console . log ( "===============================================================" ) ;
40
36
const actorId = "MyActorId1" ;
41
37
42
-
43
38
const resRegisteredActors = await server . actor . getRegisteredActors ( ) ;
44
39
console . log ( `Registered Actor Types: ${ JSON . stringify ( resRegisteredActors ) } ` ) ;
45
40
46
41
console . log ( "[Dapr-JS][Example][Actors] Trying to invoke method 'say' with msg 'hello world'" ) ;
47
- const resActorInvokeSay = await client . actor . invoke ( "PUT" , DemoActorSayImpl . name , actorId , "sayString" , "Hello World" ) ;
42
+ const actor = client . actor . create < DemoActorSayImpl > ( DemoActorSayImpl ) ;
43
+ const resActorInvokeSay = await actor . sayString ( "Hello World" ) ;
48
44
console . log ( `[Dapr-JS][Example][Actors] Invoked Method and got data: ${ resActorInvokeSay } ` ) ;
49
-
50
- let resActorStateGet = await client . actor . stateGet ( DemoActorSayImpl . name , actorId , "PropertyA" ) ;
51
- await client . actor . stateTransaction ( DemoActorSayImpl . name , actorId , [
52
- {
53
- operation : "upsert" ,
54
- request : {
55
- key : "key-1" ,
56
- value : "my-new-data-1"
57
- }
58
- } ,
59
- {
60
- operation : "upsert" ,
61
- request : {
62
- key : "key-to-delete" ,
63
- value : "my-new-data-1"
64
- }
65
- } ,
66
- {
67
- operation : "delete" ,
68
- request : {
69
- key : "key-to-delete"
70
- }
71
- }
72
- ] ) ;
73
-
74
- resActorStateGet = await client . actor . stateGet ( DemoActorSayImpl . name , actorId , "key-to-delete" ) ;
75
- console . log ( `[Dapr-JS][Example][Actors] Get State (should be empty): ${ JSON . stringify ( resActorStateGet ) } ` ) ;
76
-
77
- const resActorStateGet2 = await client . actor . stateGet ( DemoActorSayImpl . name , actorId , "key-1" ) ;
78
- console . log ( `[Dapr-JS][Example][Actors] Get State (should be my-new-data-1): ${ JSON . stringify ( resActorStateGet2 ) } ` ) ;
79
45
}
80
46
81
47
start ( ) . catch ( ( e ) => {
0 commit comments