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
`$delay` instruction can be used to delay the start of evaluation of any script. That can be useful, for example, if you need to ensure that one script starts evaluating after another script starts, but you don't need for it to wait for the completion (as in sequential processing):
@@ -420,19 +269,6 @@ The evaluation result will be the same as without `$delay` istruction, but the s
420
269
421
270
This instruction can also be used to create asynchronous value from synchronous value. For example if some executor expects an asynchronous value as an argument and you want to pass a constant, you can use `$delay`:
422
271
423
-
```json
424
-
{
425
-
"$exec": "logger",
426
-
"$method": "resolve",
427
-
"$args": {
428
-
"message": "Resolved",
429
-
"asyncValue": { "$delay": "test", "$wait": 1000 }
430
-
}
431
-
}
432
-
```
433
-
434
-
or with short syntax:
435
-
436
272
```json
437
273
{
438
274
"$$logger.resolve": {
@@ -451,34 +287,6 @@ In the example above a hypothetical logger logs message when asynchronous value
451
287
452
288
Anonymous or named function can be defined in the script to be passed to executors (either predefined or supplied by user) or simply to be used multiple times.
453
289
454
-
```json
455
-
[
456
-
{
457
-
"$func": {
458
-
"$exec": "router",
459
-
"$method": "get",
460
-
"$args": { "path": { "$data": "/path" } }
461
-
},
462
-
"$name": "getRes",
463
-
"$args": [ "path" ]
464
-
},
465
-
{
466
-
"$call": "getRes",
467
-
"$args": [ "/resource/1" ]
468
-
},
469
-
{
470
-
"$call": { "$ref": "/0" },
471
-
"$args": { "path": "/resource/2" }
472
-
},
473
-
{
474
-
"$call": { "$ref": "1/0" },
475
-
"$args": "/resource/3"
476
-
}
477
-
]
478
-
```
479
-
480
-
or with short syntax:
481
-
482
290
```json
483
291
[
484
292
{
@@ -502,32 +310,6 @@ In the example above the same function `getRes` is used three times, being calle
502
310
503
311
Functions can be used as parameters in the executors:
504
312
505
-
```json
506
-
{
507
-
"$exec": "array",
508
-
"$method": "map",
509
-
"$args": {
510
-
"data": [
511
-
"/resource/1",
512
-
"/resource/2",
513
-
"/resource/3"
514
-
],
515
-
"iterator": {
516
-
"$func": {
517
-
"$exec": "router1",
518
-
"$method": "get",
519
-
"$args": {
520
-
"path": { "$data": "/path" }
521
-
}
522
-
},
523
-
"$args": ["path"]
524
-
}
525
-
}
526
-
}
527
-
```
528
-
529
-
or with short syntax:
530
-
531
313
```json
532
314
{
533
315
"$$array.map": {
@@ -546,6 +328,8 @@ or with short syntax:
546
328
}
547
329
```
548
330
331
+
See [Array iteration](#array-iteration).
332
+
549
333
If the function was previously defined it can be passed either using `"$ref"` with an absolute or relative JSON-pointer or `{ "$func": "myfunc" }. The latter always evaluates as the reference to the existing function rather than the function that always returns string "myfunc", to define the function that always returns the same string you can use "$quote".
550
334
551
335
@@ -566,9 +350,7 @@ evaluates as: `{ "$exec": "myExec" }` and the executor is not called.
566
350
`$quote` can also be used to define the function that always returns the same string:
567
351
568
352
```json
569
-
{
570
-
"$func": { "$quote": "foo" }
571
-
}
353
+
{ "$func": { "$quote": "foo" } }
572
354
```
573
355
574
356
The anonymous function defined above always returns the string `"foo"`. Without `$quote` it would have been the reference to the function with the name `foo`.
0 commit comments