Skip to main content


The @devicescript/observables builtin module provides a lightweight reactive observable framework, a limited subset of RxJS. We highly recommend reviewing the RxJS documentation for deeper discussions about observables.

For in-depth tutorials about observables, see RxJS.


Import @devicescript/observables to enable the APIs.

import "@devicescript/observables"


Observable operators apply transformation between observable data stream. They can be combined using the pipe method to create complex data processing pipeline. Many (most) operators are adapted from Rxjs.

import { Temperature } from "@devicescript/core"
import { threshold, throttleTime } from "@devicescript/observables"

const thermometer = new Temperature()
// create a stream of temperature readings
const temperature = thermometer.reading.pipe(
threshold(0.1), // at least 0.1deg change
throttleTime(10000) // at most one update per 10s
temperature.subscribe(t => console.log(t))