0.7.0 • Published 6 years ago

zev-tiny-observable v0.7.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

TinyObservable:

by Jeremy Zevin

Why? Because I wanted to see if I could make a very simple observable that I could use with various projects. Done without looking at anyone elses code.


Install

npm install zev-tiny-observable

Usage

Browser

<script src="https://unpkg.com/zev-tiny-observable/dist/tinyObservable.min.js"></script>

module import

import TinyObservable from 'zev-tiny-observable';

API

Static Contructor Methods

new TinyObservable()

example:

const obs = new TinyObservable();
const sub = obs.subscribe(r => console.log(r));
obs.next('Hi!');

TinyObservable.fromRaf()

example:

const rafObs = new TinyObservable.fromRaf();
const rafSub = rafObs.subscribe(t => console.log(t)) // will receive t from window.requestAnimationFrame
setTimeout(() => rafSub.unsubscribe(), 1000); // will unsubscribe in 1000ms

TinyObservable.fromEvent(eventType, element)

example:

const eventObs = TinyObservable.fromEvent('mousemove', document.body);
const mouseMoveSub = eventObs.subscribe(e => console.log(e));

Subscription.unsubscribe()

example as seen above

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.2

6 years ago