Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lil-saga

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lil-saga

A small saga implementation

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Lil' Saga

Latest NPM release TravisCI Build Status

lil-saga is a small library to assist in use of the saga pattern.

Usage

lil-saga accepts a generator which may yield a Saga, a Promise, or an array containing a mix of Sagas and Promises.

If an array is yielded, the actions (and any subsequent rollbacks), will be performed concurrently.

If an error occurs during execution, any previously executed Sagas will have their undo performed, in reverse order of execution.

Example

import lilSaga from 'lil-saga';

await lilSaga(function*() {
  let promiseYieldingFunctionResult = yield promiseYieldingFunction();

  let anotherPromiseYieldingFunctionResult = yield {
    do() {
      return anotherPromiseYieldingFunction();
    },

    undo() {
      return anotherPromiseYieldingFunctionReverse();
    }
  };

  let [
    thing1,
    thing2,
    thing3
  ] = yield [
    doThing1(),
    {
      do: () => doThing2(),
      undo: () => undoThing2()
    },
    doThing3()
  ];
});

FAQs

Package last updated on 09 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc