-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #957 from thefrontside/v4-docs-suspend
📝 update the `suspend()` docs to account for v4 API
- Loading branch information
Showing
5 changed files
with
70 additions
and
189 deletions.
There are no files selected for viewing
This file contains 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,6 +1,29 @@ | ||
import { action } from "./action.ts"; | ||
import type { Operation } from "./types.ts"; | ||
|
||
/** | ||
* Indefinitely pause execution of the current operation. | ||
* | ||
* A suspended operation will remain paused until its enclosing scope | ||
* is destroyed, at which point it proceeds as though return had been | ||
* called from the point of suspension. | ||
* | ||
* @example | ||
* ```js | ||
* import { main, suspend } from "effection"; | ||
* | ||
* await main(function* (resolve) { | ||
* try { | ||
* console.log('suspending'); | ||
* yield* suspend(); | ||
* } finally { | ||
* console.log('done!'); | ||
* } | ||
* }); | ||
* ``` | ||
* | ||
* @returns an operation that suspends the current operation | ||
*/ | ||
export function suspend(): Operation<void> { | ||
return action(() => () => {}, "suspend"); | ||
} |
This file contains 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 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 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 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