# callbag-lazy

> Callbag source for lazy evaluation

Latest version **2.0.2** (published 2020-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install callbag-lazy
pnpm add callbag-lazy
yarn add callbag-lazy
bun add callbag-lazy
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2020-05-21 |
| First published | 2018-04-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Francisco Tavares de Lima Neto |
| Maintainers | francisco.tln |
| Keywords | callbag |

## Links

- npm: https://www.npmjs.com/package/callbag-lazy
- Repository: https://github.com/franciscotln/callbag-lazy
- Homepage: https://github.com/franciscotln/callbag-lazy#readme
- Issues: https://github.com/franciscotln/callbag-lazy/issues
- npm.io page: https://npm.io/package/callbag-lazy

## Dependencies (1)

- [callbag](https://npm.io/package/callbag.md) 1.2.0

## Recent versions

- 2.0.2 (latest) — 2020-05-21
- 2.0.1 — 2019-02-05
- 2.0.0 — 2018-10-26
- 1.0.3 — 2018-09-01
- 1.0.2 — 2018-04-19
- 1.0.1 — 2018-04-17
- 1.0.0 — 2018-04-17

## README

# callbag-lazy

Callbag source for lazy evaluation at subscription time.
Weighs <span class="weight">98</span> bytes (minified & gzipped).

`npm install callbag-lazy`

## Example

### window inner width
```js
const lazy = require('callbag-lazy');
const subscribe = require('callbag-subscribe')

const src = lazy(() => window.innerWidth);

const observer = {
  next(v) {
    console.log(`Next(${v})`);
  },
  complete() {
    console.log('Done()');
  }
};

setTimeout(() => subscribe(observer)(src), 2000);
// logs the window width at subscription time then logs 'Done()'
```

This source is equivalent to the sources below:

```js
const create = require('callbag-create');
const { fromIter, map, pipe } = require('callbag-basics');

const src1 = pipe(
  fromIter([() => window.innerWidth]),
  map(f => f())
);

const src2 = create((sink) => {
  sink(1, window.innerWith);
  sink(2);
});
```

---
_Source: https://npm.io/package/callbag-lazy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
