File tree 2 files changed +36
-2
lines changed
docs/docs/04-standard-library/01-cloud
2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,24 @@ new cloud.Function(counterFunc);
51
51
52
52
### Using keys to manage multiple counter values
53
53
54
- 🚧 Not implemented yet (tracking issue: [ #1375 ] ( https://github.com/winglang/wing/issues/1375 ) )
54
+ ``` js playground
55
+ bring cloud;
56
+
57
+ let counter = new cloud.Counter (initial: 100 );
58
+
59
+ let counterFunc = inflight () => {
60
+ let k1 = " key-1" ;
61
+ let k2 = " key-2" ;
62
+
63
+ counter .dec (1 , k1); // decrement k1 by 1
64
+ counter .inc (11 , k2); // increment k2 by 11
65
+
66
+ assert (counter .peek (k1) == 99 ); // check the current value of k1
67
+ assert (counter .peek (k2) == 111 ); // check the current value of k2
68
+ };
69
+
70
+ new cloud.Function (counterFunc);
71
+ ```
55
72
56
73
## Target-specific details
57
74
Original file line number Diff line number Diff line change @@ -51,7 +51,24 @@ new cloud.Function(counterFunc);
51
51
52
52
### Using keys to manage multiple counter values
53
53
54
- 🚧 Not implemented yet (tracking issue: [ #1375 ] ( https://github.com/winglang/wing/issues/1375 ) )
54
+ ``` js playground
55
+ bring cloud;
56
+
57
+ let counter = new cloud.Counter (initial: 100 );
58
+
59
+ let counterFunc = inflight () => {
60
+ let k1 = " key-1" ;
61
+ let k2 = " key-2" ;
62
+
63
+ counter .dec (1 , k1); // decrement k1 by 1
64
+ counter .inc (11 , k2); // increment k2 by 11
65
+
66
+ assert (counter .peek (k1) == 99 ); // check the current value of k1
67
+ assert (counter .peek (k2) == 111 ); // check the current value of k2
68
+ };
69
+
70
+ new cloud.Function (counterFunc);
71
+ ```
55
72
56
73
## Target-specific details
57
74
You can’t perform that action at this time.
0 commit comments