How to use effection - 10 common examples

To help you get started, we’ve selected a few effection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thefrontside / effection.js / tests / typescript / sequence.good.ts View on Github external
function* sequence(): Sequence {
  //bare generator function is ok
  let value: number = yield function*() { return 5; }

  // you can always yield undefined;
  yield;

  // other Operation also ok.
  yield sequence

  // can yield to forks
  yield fork(function*() { yield });
}
github thefrontside / effection.js / tests / typescript / sequence.good.ts View on Github external
function* asynchronous(): Sequence {
  fork(sequence);
  fork(sequence());
}
github thefrontside / effection.js / tests / typescript / execute.good.ts View on Github external
import { Execution, Sequence, fork } from 'effection';

function* operation(): Sequence {}

let execution: Execution;

execution = fork(operation);

execution = fork(operation());

execution = fork(Promise.resolve("hello world"));

execution = fork(function*() {});

execution = fork(undefined);

execution = fork((execution: Execution) => {
  execution.id;
  execution.resume(10);
  execution.halt("optional reason");
  execution.halt();
  execution.throw(new Error('boom!'));
});
github thefrontside / effection.js / tests / typescript / execute.good.ts View on Github external
import { Execution, Sequence, fork } from 'effection';

function* operation(): Sequence {}

let execution: Execution;

execution = fork(operation);

execution = fork(operation());

execution = fork(Promise.resolve("hello world"));

execution = fork(function*() {});

execution = fork(undefined);

execution = fork((execution: Execution) => {
  execution.id;
  execution.resume(10);
  execution.halt("optional reason");
  execution.halt();
  execution.throw(new Error('boom!'));
});
github thefrontside / effection.js / tests / typescript / sequence.good.ts View on Github external
function* asynchronous(): Sequence {
  fork(sequence);
  fork(sequence());
}
github thefrontside / effection.js / tests / typescript / promise.ts View on Github external
async function someAsyncFunction() {
  await fork(function*() {
    yield
  });

  await Promise.all([
    fork(function*() { yield }),
    fork(function*() { yield }),
  ]);

  let someFork = fork(function*() {
    yield
    return 123;
  });

  someFork.then((value: number) => {}, (error) => {});
  someFork.catch((error: Error) => "string").then((some: string) => {});
  someFork.finally(() => "string").then((some: number) => {});
}
github thefrontside / effection.js / tests / typescript / execute.good.ts View on Github external
import { Execution, Sequence, fork } from 'effection';

function* operation(): Sequence {}

let execution: Execution;

execution = fork(operation);

execution = fork(operation());

execution = fork(Promise.resolve("hello world"));

execution = fork(function*() {});

execution = fork(undefined);

execution = fork((execution: Execution) => {
  execution.id;
  execution.resume(10);
  execution.halt("optional reason");
  execution.halt();
  execution.throw(new Error('boom!'));
});
github thefrontside / effection.js / tests / typescript / execute.good.ts View on Github external
function* operation(): Sequence {}

let execution: Execution;

execution = fork(operation);

execution = fork(operation());

execution = fork(Promise.resolve("hello world"));

execution = fork(function*() {});

execution = fork(undefined);

execution = fork((execution: Execution) => {
  execution.id;
  execution.resume(10);
  execution.halt("optional reason");
  execution.halt();
  execution.throw(new Error('boom!'));
});
github thefrontside / effection.js / tests / typescript / execute.good.ts View on Github external
import { Execution, Sequence, fork } from 'effection';

function* operation(): Sequence {}

let execution: Execution;

execution = fork(operation);

execution = fork(operation());

execution = fork(Promise.resolve("hello world"));

execution = fork(function*() {});

execution = fork(undefined);

execution = fork((execution: Execution) => {
  execution.id;
  execution.resume(10);
  execution.halt("optional reason");
  execution.halt();
  execution.throw(new Error('boom!'));
});

effection

Structured concurrency and effects for JavaScript

MIT
Latest version published 2 months ago

Package Health Score

76 / 100
Full package analysis

Popular effection functions