Published
Edited
Oct 2, 2019
1 fork
1 star
Insert cell
Insert cell
Insert cell
uptime$ = obs.interval(1000).publish()
Insert cell
uptime$.take(30).view()
Insert cell
//uptime$.connect()
Insert cell
uptime$.take(30).map(util.colored).view()
Insert cell
//sub = uptime$.connect()
Insert cell
//sub.unsubscribe()
Insert cell
util.random()
Insert cell
random$ = obs.of(1).repeat().map(util.random).do(spy(2).set).take(10).publish()
Insert cell
// without take, with publishReplay
Insert cell
spy(2).values()
Insert cell
random$.connect()
Insert cell
random$.take(20).view()
Insert cell
randomclix$ = clix$.zip(random$).pluck(1).shareReplay()
Insert cell
randomclix$.view()
Insert cell
randomclix$.view()
Insert cell
Insert cell
obs.zip( obs.interval(50)
.do(spy(2).set)
.take(50),
obs.interval(200)
.take(50) )
.value()
Insert cell
spy(2).value()
Insert cell
obs.interval(100).do(spy(3).set).take(100).concatMap( x => obs.of(x).delay(1000) ).view()
Insert cell
spy(3).value()
Insert cell
Insert cell
subject = new rx.Subject()
Insert cell
subject.view()
Insert cell
//subject.next(1)
Insert cell
//subject.error("ouch")
Insert cell
//subject.complete()
Insert cell
//obs.interval(1000).take(30).subscribe(subject)
Insert cell
subject.next("yellow")
Insert cell
//
Insert cell
viewof s1 = html`<input type=range>`
Insert cell
s1
Insert cell
s1sub = new rx.Subject()
Insert cell
s1sub.next(s1)
Insert cell
s1sub.view()
Insert cell
s1d = s1sub.debounceTime(200)
Insert cell
s1d.value()
Insert cell
s1d.view()
Insert cell
Insert cell
initial_value = "john"
Insert cell
viewof user = html`<input type=text value="${initial_value}">`
Insert cell
user$ = new rx.BehaviorSubject(initial_value)
Insert cell
user$.next(user)
Insert cell
user$.skip(1).debounceTime(200).distinctUntilChanged().map(s => html`Showing result for: <b>${s}`).value()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more