Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/riophae/combine-callbacks
Combine multiple callbacks into one.
https://github.com/riophae/combine-callbacks
Last synced: about 1 month ago
JSON representation
Combine multiple callbacks into one.
- Host: GitHub
- URL: https://github.com/riophae/combine-callbacks
- Owner: riophae
- Created: 2015-10-16T10:38:23.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-05T03:19:03.000Z (almost 9 years ago)
- Last Synced: 2024-11-04T06:35:20.001Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# combine-callbacks
[![npm version](https://badge.fury.io/js/combine-callbacks.svg)](https://badge.fury.io/js/combine-callbacks) [![Build Status](https://travis-ci.org/riophae/combine-callbacks.svg)](https://travis-ci.org/riophae/combine-callbacks) [![Dependency Status](https://david-dm.org/riophae/combine-callbacks.svg)](https://david-dm.org/riophae/combine-callbacks) [![Coverage Status](https://coveralls.io/repos/riophae/combine-callbacks/badge.svg?branch=master&service=github)](https://coveralls.io/github/riophae/combine-callbacks?branch=master)
Combine multiple callbacks into one. Divide up code into smaller units. Improve the reusability & make the code clearer.
## Installation
```bash
$ npm install combine-callbacks
```## Usage
```js
var combineCallbacks = require('combine-callbacks');var preventDefault = function(evt) { evt.preventDefault(); };
var dispatchAction = function() { ... };var onClick = combineCallbacks(preventDefault, dispatchAction);
document.getElementById('elem').addEventListener('click', onClick);
```For more examples see the test.
## API
### combineCallbacks(fn1[, fn2[, fn3...]])
Returns the final combined callback which receives arguments & context, and then passes them into the original functions.### combineCallbacks(arrayOfFuncs)
You get the idea.## License
MIT License, Copyright (c) 2015 Riophae Lee