https://github.com/cheton/chained-function
Chained function calls
https://github.com/cheton/chained-function
chained function
Last synced: 5 months ago
JSON representation
Chained function calls
- Host: GitHub
- URL: https://github.com/cheton/chained-function
- Owner: cheton
- License: mit
- Created: 2017-02-16T08:19:12.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-08-27T11:52:04.000Z (over 6 years ago)
- Last Synced: 2025-07-03T18:35:10.018Z (6 months ago)
- Topics: chained, function
- Language: JavaScript
- Size: 4.88 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome_frontend_development_resources - chained-function - Chained function calls. (Utilities / React Components)
- awesome - chained-function - Chained function calls. (Utilities / React Components)
README
# chained-function [](https://travis-ci.org/cheton/chained-function) [](https://coveralls.io/github/cheton/chained-function?branch=master)
[](https://www.npmjs.com/package/chained-function)
## Installation
```bash
npm install --save chained-function
```
## Usage
```js
let sum = 0;
const func = chainedFunction(
function(val) {
sum += val;
console.log(sum); // 2
},
function(val) {
sum += val;
console.log(sum); // 4
},
function(val) {
sum += val;
console.log(sum); // 6
}
);
func(2);
```
### React
```js
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import chainedFunction from 'chained-function';
class extends Component {
static propTypes = {
onClick: PropTypes.func
};
static contextTypes = {
$parent: PropTypes.shape({
onClick: PropTypes.func
})
};
actions = {
handleClick: (event) => {
}
}
render() {
const { onClick, ...props } = this.props;
const parent = this.context.$parent;
## License
MIT