https://github.com/doodzik/frp-dsl
an abstraction for adding minimal functional reactive middelware functionality
https://github.com/doodzik/frp-dsl
Last synced: 11 months ago
JSON representation
an abstraction for adding minimal functional reactive middelware functionality
- Host: GitHub
- URL: https://github.com/doodzik/frp-dsl
- Owner: doodzik
- License: gpl-3.0
- Created: 2015-11-15T20:06:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-17T16:15:01.000Z (over 10 years ago)
- Last Synced: 2025-08-02T03:22:55.281Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# FRP Middelware
[](https://travis-ci.org/doodzik/frp-middleware)
This module aims to ease building middleware DSL's.
It implements a basic functional reactive programming Interface.
# Installation
```bash
$ npm install frp-middelware --save
```
# Usage
### how to use an Stream
```javascript
let stream = new SomeStream()
stream.map(data => data + '!!!') // => hello world!!!
.fork(data => data + '???') // => hello world!!!???
.map(data => data + '...') // => hello world!!!...
// invokes the stream
stream.subscribe()
```
### how to write your own Stream
```javascript
import Middleware from 'frp-middleware'
class SomeStream extends Middleware {
subscribe() { // or you could use the 'emit' method. it is the same thing
const middleware = super.subscribe()
setIntervall(() => middleware('hello world'), 500)
}
}
```
# API
### \#map
changes the data in the stream and passes the altered data to the next function in the pipeline
### \#fork
Forks a stream and applies a function to it.
The child stream runs independently of the parent stream.
### \#subscribe
Returns the middleware function
Should be implemented as a way to start listening to the stream.
### \#emit
Returns the middleware function.
Should be implemented as a way to fire events on the stream.
# Examples
[plain-tcp](https://github.com/doodzik/plain-tcp)