@@ -10,10 +10,6 @@ const serverHost = "127.0.0.1"; // App Host of this Example Server
1010const serverPort = "50001" ; // App Port of this Example Server
1111const daprAppId = "example-hello-world" ;
1212
13- async function sleep ( ms : number ) : Promise < void > {
14- return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
15- }
16-
1713async function start ( ) {
1814 const server = new DaprServer ( serverHost , serverPort , daprHost , daprPort ) ;
1915 const client = new DaprClient ( daprHost , daprPort ) ;
@@ -39,43 +35,13 @@ async function start() {
3935 console . log ( "===============================================================" ) ;
4036 const actorId = "MyActorId1" ;
4137
42-
4338 const resRegisteredActors = await server . actor . getRegisteredActors ( ) ;
4439 console . log ( `Registered Actor Types: ${ JSON . stringify ( resRegisteredActors ) } ` ) ;
4540
4641 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" ) ;
4844 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 ) } ` ) ;
7945}
8046
8147start ( ) . catch ( ( e ) => {
0 commit comments