Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atomrc/callbag-debounce
Debounce ⏱ operator for Callbag 👜
https://github.com/atomrc/callbag-debounce
callbag
Last synced: 16 days ago
JSON representation
Debounce ⏱ operator for Callbag 👜
- Host: GitHub
- URL: https://github.com/atomrc/callbag-debounce
- Owner: atomrc
- License: mit
- Created: 2018-02-28T22:06:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T02:35:00.000Z (over 1 year ago)
- Last Synced: 2024-10-20T07:45:28.749Z (24 days ago)
- Topics: callbag
- Language: TypeScript
- Homepage:
- Size: 97.7 KB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - debounce
README
# Callbag debounce
Debounce operator for [Callbag](https://github.com/callbag/callbag)
## Install
npm i callbag-debounce
## Example
Debounces the `scroll` event and runs the `expensiveFunction` only when there is a 60ms pause.
```javascript
const { fromEvent, forEach, pipe } = require("callbag-basics");
import { debounce } from "callbag-debounce";pipe(
fromEvent(document, "scroll"),
debounce(60),
forEach(expensiveFunction)
);
```## Changelog
### 4.0.0 (21/06/2021)
BREAKING CHANGE:
- Last value is flushed even if the stream is receiving a terminate signal before the value has been debounced (fixes [#12](https://github.com/atomrc/callbag-debounce/pull/12))
Before
```js
pipe(
of(42),
debounce(1000),
subscribe(console.log)
)
// Terminates without logging anything
```After
```js
pipe(
of(42),
debounce(1000),
subscribe(console.log)
)
// logs 42
// Then terminates
```### 3.0.0 (05/03/2021)
BREAKING CHANGE:
- Timer is cleared when stream is terminated by sink (see [#13](https://github.com/atomrc/callbag-debounce/pull/13))
### v2.1.0 (05/03/2018)
- `error` (`t === 2 && d !== undefined`) signals are sent right away (previously they were delayed according to the `wait` parameter);
- `complete` (`t === 2 && d === undefined`) signals are sent when the last value is debounced (previously they were debounced according to the `wait` parameter).### v2.0.0 (01/03/2018)
codebase migrated to TypeScript.
The module needs to be imported via a named import```javascript
import { debounce } from "callbag-debounce";
```previously
```javascript
import debounce from "callbag-debounce";
```