taskarian
Options
All
  • Public
  • Public/Protected
  • All
Menu

taskarian

A Task (Future) implementation in TypeScript. Useful for managing asynchronous tasks that may fail.

A Task is different then a Promise because it is lazy, rather then eager. A Promise runs as soon as you instantiate it. A Task doesn't run until you call fork. Pure functions can return tasks (just not execute them). This means that you could, for example, return a task from a Redux reducer, if that's your thing.

install

npm install --save taskarian

yarn add taskarian

usage

import Task from 'taskarian';

function parse(s) {
  return new Task(function(reject, resolve) {
    try {
      resolve(JSON.parse(s));
    }
    catch(e) {
      reject(e.message);
    }
  });
}

parse('foo').fork(
  function(err) { console.error(err) },
  function(value) { console.log(value) }
);

docs

API

Index

External modules

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc