Request re-execution during processing Even when you come back and forth, you only re-execute once
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
lib
tasks
test
.babelrc
.editorconfig
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
package.json
task.config.js
yarn.lock

README.md

Soshoku

XO code style

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

Install or Download

yarn add soshoku
npm i -S soshoku

Or access to releases page. Then, download the latest version.

Usage

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

or

<script src="/path/tp/soshoku.js"></script>

API

constructor(func)

  • func: Promise

Register function.

exec()

Execute function.

Example

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 nju33.ki@gmail.com