# obv

> simple and lightweight observer

Latest version **0.0.1** (published 2017-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install obv
pnpm add obv
yarn add obv
bun add obv
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2017-01-03 |
| First published | 2016-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | 'Dominic Tarr' |
| Maintainers | dominictarr |

## Links

- npm: https://www.npmjs.com/package/obv
- Repository: https://github.com/dominictarr/obv
- Issues: https://github.com/dominictarr/obv/issues
- npm.io page: https://npm.io/package/obv

## Recent versions

- 0.0.1 (latest) — 2017-01-03
- 0.0.0 — 2016-11-03

## README

# obv

Represents a value changing in time.

Sometimes you have a sequence of values over time,
usually we use streams for this. However, in some cases,
the latest value, or the next value matters more
than the entire history of values.

For example, if you are drawing the mouse pointer,
you just need the current position, not the historical positions.

An observable is a simple way to represent these instantaniously changing values.

## Obv() => observable

returns an observable instance.

## observable(listener=function, immediate=boolean) => remove

register `listener` with the observable. `immediate` is true by default.
`listener` is called with the current value (if one has been set), set to false to disable.

A function `remove` is returned, calling this function deregisters the listener.

## observable.set(value=any)

set the current value of this observable. Any registered listeners will be called.

## observable.once(listener=function, immediate=boolean) => remove

Like the above call to `observable()` except the listener will only be triggered _once_.

This is useful for representing variables which must be set after an async operation
(say, initializing a database connection), but if the value is initalized
you can act on it immediately.

If you call `observable.once(listener, false)` that triggers at the _next_
time the value is set, which so far I have used to create live streams.

## observable.value

The current value of the observable is provided as a property.
I recommend not using null as a observable value in your program,
because it makes testing the current value awkward.

## License

MIT

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