Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nju33/soshoku

Request re-execution during processing Even when you come back and forth, you only re-execute once
https://github.com/nju33/soshoku

promise

Last synced: about 2 months ago
JSON representation

Request re-execution during processing Even when you come back and forth, you only re-execute once

Awesome Lists containing this project

README

        

# Soshoku

[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)

Request re-execution during processing Even when you come back and forth, you only re-execute once.

## Install or Download

```sh
yarn add soshoku
npm i -S soshoku
```

Or access to [releases page](https://github.com/nju33/soshoku/releases).
Then, download the latest version.

## Usage

```js
import soshoku from 'soshoku';
const soshoku = require('soshoku');
```

or

```html

```

### API

#### `constructor(func)`

- `func`: `Promise`

Register function.

#### `exec()`

Execute function.

### Example

```js
import Soshoku from 'soshoku';

const doSomethingAsync = () => {
return new Promise(resolve => {
setTimeout(() => {
console.log('called!');
resolve();
}, 5000)
});
}

new soshoku = new Soshoku(doSomethingAsync);

soshoku.exec();
setTimeout(soshoku.exec, 1000);
setTimeout(soshoku.exec, 2000);

// The result comes out as 'called!' After 5s.
// And after 5s we also get 'called!'.
// But after 5s there is nothing.
```

## LICENSE

The MIT License (MIT)

Copyright (c) 2017 nju33