-
Notifications
You must be signed in to change notification settings - Fork 89
fix: Fact-check of scheduling #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Swiftaxe
wants to merge
1
commit into
main
Choose a base branch
from
fix/fact-check-scheduling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,10 +1,14 @@ | ||||||
| --- | ||||||
| description: The legacy string-based API for registering and scheduling future calls, prefer the type-safe API for new code. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: the comma joins two clauses where a period would read cleaner.
Suggested change
|
||||||
| --- | ||||||
|
|
||||||
| # Legacy | ||||||
|
|
||||||
| :::warning | ||||||
| This approach is error prone since it involves manually registering and scheduling future calls using string identifiers. The recommended way to interact with the future calls feature is through the [type-safe API](setup). | ||||||
| ::: | ||||||
|
|
||||||
| Creating a future call is simple, extend the `FutureCall` class and override the `invoke` method. The method takes two params the first being the [`Session`](../sessions) object and the second being an optional SerializableModel ([See models](../models)). | ||||||
| To create a future call, extend the `FutureCall` class and override the `invoke` method. The method takes two params: the first is a [`Session`](../sessions) object and the second is an optional serializable model ([See models](../models)). | ||||||
|
|
||||||
| ```dart | ||||||
| import 'package:serverpod/serverpod.dart'; | ||||||
|
|
@@ -17,7 +21,7 @@ class ExampleFutureCall extends FutureCall<MyModelEntity> { | |||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| To let your Server get access to the future call you have to register it in the main run method in your `server.dart` file. You register the future call by calling `registerFutureCall` on the Serverpod object and giving it an instance of the future call together with a string that gives the future call a name. The name has to be globally unique and is used to later invoke the future call. | ||||||
| Register the future call in the `run` function in your `server.dart` file by calling `registerFutureCall` with an instance of the class and a globally unique name string. The name is used to invoke the future call later. | ||||||
|
|
||||||
| ```dart | ||||||
| void run(List<String> args) async { | ||||||
|
|
@@ -35,7 +39,7 @@ void run(List<String> args) async { | |||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| You are now able to register a future call to be invoked in the future by calling either `futureCallWithDelay` or `futureCallAtTime` depending on your needs. | ||||||
| With the future call registered, you can schedule it using either `futureCallWithDelay` or `futureCallAtTime` depending on your needs. | ||||||
|
|
||||||
| Invoke the future call 1 hour from now by calling `futureCallWithDelay`. | ||||||
|
|
||||||
|
|
@@ -53,12 +57,12 @@ Invoke the future call at a specific time and/or date in the future by calling ` | |||||
| await session.serverpod.futureCallAtTime( | ||||||
| 'exampleFutureCall', | ||||||
| data, | ||||||
| DateTime(2025, 1, 1), | ||||||
| DateTime(2030, 1, 1), | ||||||
| ); | ||||||
| ``` | ||||||
|
|
||||||
| :::note | ||||||
| `data` is an object created from a class defined in one of your yaml files and has to be the same as the one you expect to receive in the future call. in the `model` folder, `data` may also be null if you don't need it. | ||||||
| `data` is an object created from a class defined in one of your yaml model files and must match the type expected by the future call. `data` may also be `null` if you don't need it. | ||||||
| ::: | ||||||
|
|
||||||
| When registering a future call, it is also possible to give it an `identifier` so that it can be referenced later. The same identifier can be applied to multiple future calls. | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: em dash slipped in here. A colon keeps the same structure.