Skip to content

Commit

Permalink
Merge branch 'v3' into release-3.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
taras authored Jan 2, 2024
2 parents 0e1adfc + b8f8c44 commit e51b3c1
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/abort-signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { resource } from "./instructions.ts";
* lifetime of the HTTP request to the lifetime of the current task.
*
* @example
* ```js
* ```javascript
* function* request() {
* let signal = yield* useAbortSignal();
* return yield* fetch('/some/url', { signal });
Expand Down
13 changes: 7 additions & 6 deletions lib/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { pause } from "./pause.ts";
* APIs that accept `Callable` values allow end developers to pass simple
* functions without necessarily needing to know anything about Operations.
*
* @example
* ```javascript
* function hello(to: Callable<string>): Operation<string> {
* return function*() {
* return `hello ${yield* call(to)}`;
Expand All @@ -22,6 +22,7 @@ import { pause } from "./pause.ts";
* await run(() => hello(() => "world!")); // => "hello world!"
* await run(() => hello(async () => "world!")); // => "hello world!"
* await run(() => hello(function*() { return "world!" })); "hello world!";
* ```
*/
export type Callable<T> =
| Operation<T>
Expand All @@ -42,14 +43,14 @@ export type Callable<T> =
* It can be used to treat a promise as an operation:
*
* @example
* ```js
* ```javascript
* let response = yield* call(fetch('https://google.com'));
* ```
*
* or an async function:
*
* @example
* ```ts
* ```typescript
* async function* googleSlowly() {
* return yield* call(async function() {
* await new Promise(resolve => setTimeout(resolve, 2000));
Expand All @@ -62,7 +63,7 @@ export type Callable<T> =
* resources allocated will be cleaned up:
*
* @example
* ```js
* ```javascript
* yield* call(function*() {
* let socket = yield* useSocket();
* return yield* socket.read();
Expand All @@ -72,15 +73,15 @@ export type Callable<T> =
* It can be used to run a plain function:
*
* @example
* ```js
* ```javascript
* yield* call(() => "a string");
* ```
*
* Because `call()` runs within its own {@link Scope}, it can also be used to
* establish {@link * establish error boundaries https://frontside.com/effection/docs/errors | error boundaries}.
*
* @example
* ```js
* ```javascript
* function* myop() {
* let task = yield* spawn(function*() {
* throw new Error("boom!");
Expand Down
4 changes: 2 additions & 2 deletions lib/ensure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { resource } from "./instructions.ts";
* shuts down. This is equivalent to running the function or operation
* in a `finally {}` block, but it can help you avoid rightward drift.
*
* @example <caption>using a function</caption>
* @example
*
* ```javascript
* import { main, ensure } from 'effection';
Expand All @@ -21,7 +21,7 @@ import { resource } from "./instructions.ts";
* Note that you should wrap the function body in braces, so the function
* returns `undefined`.
*
* @example <caption>using operation</caption>
* @example
*
* ```javascript
* import { main, ensure, once } from 'effection';
Expand Down
2 changes: 1 addition & 1 deletion lib/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export function spawn<T>(operation: () => Operation<T>): Operation<Task<T>> {
* scope.
*
* @example
* ```js
* ```javascript
* function useWebSocket(url) {
* return resource(function*(provide) {
* let socket = new WebSocket(url);
Expand Down
2 changes: 1 addition & 1 deletion lib/lift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type Operation } from "./types.ts";
* Convert a simple function into an {@link Operation}
*
* @example
* ```js
* ```javascript
* let log = lift((message) => console.log(message));
*
* export function* run() {
Expand Down
2 changes: 1 addition & 1 deletion lib/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export * from "./run/scope.ts";
* whole program using Effection, you should prefer {@link main}.
*
* @example
* ```
* ```javascript
* import { run, useAbortSignal } from 'effection';
*
* async function fetchExample() {
Expand Down
2 changes: 1 addition & 1 deletion lib/run/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function* useScope(): Operation<Scope> {
* the creator of the new scope to destroy it when it is no longer needed.
*
* @example
* ```js
* ```javascript
* let [scope, destroy] = createScope();
* let task = scope.run(function*() {
* //do some long running work
Expand Down
2 changes: 1 addition & 1 deletion lib/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createContext } from "./context.ts";
* Signals are particularly suited to be installed as event listeners.
*
* @example
* ```ts
* ```typescript
* import { createSignal, each } from "effection";
*
* export function* logClicks(function*(button) {
Expand Down
4 changes: 2 additions & 2 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { Computation } from "./deps.ts";
* to other operations:
*
* @example
* ```js
* ```javascript
* import { sleep } from "effection";
* function* slow5(seconds) {
Expand All @@ -26,7 +26,7 @@ import type { Computation } from "./deps.ts";
* operation is the same as above:
*
* @example
* ```js
* ```javascript
* import { sleep } from "effection";
*
* const slow5 = (seconds) => ({
Expand Down

0 comments on commit e51b3c1

Please sign in to comment.