Skip to content

Commit 7bfb1cd

Browse files
fix: Minor improvement to the future calls setup guide based on Discord feedback (#401)
1 parent 7fba0b1 commit 7bfb1cd

2 files changed

Lines changed: 46 additions & 30 deletions

File tree

docs/06-concepts/14-scheduling/01-setup.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,44 @@ class ExampleFutureCall extends FutureCall {
2424
For a method to be recognized by Serverpod as a future call, it must return a `Future<void>` and take at least two parameters. The first parameter must be a [`Session`](../sessions) object. You can pass any serializable types as other parameters, and even use `List`, `Map`, `Set` or Dart records as long as they are typed. `Streaming` parameters are not supported.
2525
:::
2626

27+
:::warning
28+
It is not valid to override the `invoke` method of the `FutureCall` class. This method is reserved for the execution of the future call.
29+
:::
30+
2731
Next, you need to generate the code for your future calls:
2832

2933
```bash
3034
$ serverpod generate
3135
```
3236

33-
`serverpod generate` will create a type-safe interface for invoking the future calls in the server's `generated/future_calls.dart` file. This interface can be accessed from the Serverpod object.
37+
Calling `serverpod generate` will create a type-safe interface for invoking the future calls in the server's `generated/future_calls.dart` file. This interface can be accessed from the Serverpod object.
3438

3539
The future calls you create are registered by `Serverpod` after the server starts.
3640

3741
```dart
38-
import 'package:serverpod/serverpod.dart';
39-
import 'package:serverpod_auth_idp_server/core.dart';
40-
41-
import 'src/generated/protocol.dart';
42-
import 'src/generated/endpoints.dart';
43-
44-
void run(List<String> args) async {
45-
final pod = Serverpod(
46-
args,
47-
Protocol(),
48-
Endpoints(),
49-
);
50-
51-
await pod.start();
42+
import 'package:serverpod/serverpod.dart';
43+
import 'package:serverpod_auth_idp_server/core.dart';
44+
45+
import 'src/generated/protocol.dart';
46+
import 'src/generated/endpoints.dart';
47+
48+
void run(List<String> args) async {
49+
final pod = Serverpod(
50+
args,
51+
Protocol(),
52+
Endpoints(),
53+
);
54+
55+
await pod.start();
5256
}
5357
```
5458

5559
You are now able to schedule future calls to be invoked in the future by calling either `callWithDelay` or `callAtTime` depending on your needs.
5660

61+
:::note
62+
The `futureCalls` getter is only available if at least one future call has been defined.
63+
:::
64+
5765
:::warning
5866
Scheduling a future call before the server starts will lead to exceptions.
5967
:::

versioned_docs/version-3.2.0/06-concepts/14-scheduling/01-setup.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,44 @@ class ExampleFutureCall extends FutureCall {
2424
For a method to be recognized by Serverpod as a future call, it must return a `Future<void>` and take at least two parameters. The first parameter must be a [`Session`](../sessions) object. You can pass any serializable types as other parameters, and even use `List`, `Map`, `Set` or Dart records as long as they are typed. `Streaming` parameters are not supported.
2525
:::
2626

27+
:::warning
28+
It is not valid to override the `invoke` method of the `FutureCall` class. This method is reserved for the execution of the future call.
29+
:::
30+
2731
Next, you need to generate the code for your future calls:
2832

2933
```bash
3034
$ serverpod generate
3135
```
3236

33-
`serverpod generate` will create a type-safe interface for invoking the future calls in the server's `generated/future_calls.dart` file. This interface can be accessed from the Serverpod object.
37+
Calling `serverpod generate` will create a type-safe interface for invoking the future calls in the server's `generated/future_calls.dart` file. This interface can be accessed from the Serverpod object.
3438

3539
The future calls you create are registered by `Serverpod` after the server starts.
3640

3741
```dart
38-
import 'package:serverpod/serverpod.dart';
39-
import 'package:serverpod_auth_idp_server/core.dart';
40-
41-
import 'src/generated/protocol.dart';
42-
import 'src/generated/endpoints.dart';
43-
44-
void run(List<String> args) async {
45-
final pod = Serverpod(
46-
args,
47-
Protocol(),
48-
Endpoints(),
49-
);
50-
51-
await pod.start();
42+
import 'package:serverpod/serverpod.dart';
43+
import 'package:serverpod_auth_idp_server/core.dart';
44+
45+
import 'src/generated/protocol.dart';
46+
import 'src/generated/endpoints.dart';
47+
48+
void run(List<String> args) async {
49+
final pod = Serverpod(
50+
args,
51+
Protocol(),
52+
Endpoints(),
53+
);
54+
55+
await pod.start();
5256
}
5357
```
5458

5559
You are now able to schedule future calls to be invoked in the future by calling either `callWithDelay` or `callAtTime` depending on your needs.
5660

61+
:::note
62+
The `futureCalls` getter is only available if at least one future call has been defined.
63+
:::
64+
5765
:::warning
5866
Scheduling a future call before the server starts will lead to exceptions.
5967
:::

0 commit comments

Comments
 (0)