<commit_before>[![Build Status](https://travis-ci.org/interlock/promise-interactor.svg?branch=master)](https://travis-ci.org/interlock/promise-interactor)
[![Dependency Status](https://david-dm.org/interlock/promise-interactor.svg)](https://david-dm.org/interlock/promise-interactor.svg)

# Interactors

[![Greenkeeper badge](https://badges.greenkeeper.io/interlock/promise-interactor.svg)](https://greenkeeper.io/)

Based on the popular ruby gem [Interactor](https://github.com/collectiveidea/interactor). Uses chainable promises to allow
flow of completing multiple interactors.


## TODO

- Organizer pattern

## Single Pattern

```js
class AuthenticateUser extends Interactor {
  
  // optional before, if it returns a promise it is inserted in the promise chain
  before() {
    return Promise.resolve(true);
  }
  
  call() {
    User.find({email: context.email}).then((user) => {<commit_msg>Place badge with the rest<commit_after>[![Build Status](https://travis-ci.org/interlock/promise-interactor.svg?branch=master)](https://travis-ci.org/interlock/promise-interactor)
[![Dependency Status](https://david-dm.org/interlock/promise-interactor.svg)](https://david-dm.org/interlock/promise-interactor.svg)
[![Greenkeeper badge](https://badges.greenkeeper.io/interlock/promise-interactor.svg)](https://greenkeeper.io/)

# Interactors

Based on the popular ruby gem [Interactor](https://github.com/collectiveidea/interactor). Uses chainable promises to allow
flow of completing multiple interactors.


## TODO

- Organizer pattern

## Single Pattern

```js
class AuthenticateUser extends Interactor {
  
  // optional before, if it returns a promise it is inserted in the promise chain
  before() {
    return Promise.resolve(true);
  }
  
  call() {
    User.find({email: context.email}).then((user) => {
{'fraction_non_alphanumeric': 0.14499169894853348, 'fraction_numerical': 0.0, 'mean_word_length': 4.908496732026144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1100926', 'n_tokens_mistral': 567, 'n_tokens_neox': 551, 'n_words': 112}