Observe all departures/arrivals/etc. returned by a hafas-client
instance.
npm install observe-hafas-client
const createHafas = require('db-hafas')
const {EventEmitter} = require('events')
const observe = require('observe-hafas-client')
const hafas = createHafas('my-awesome-program')
// set up observing
const observer = new EventEmitter()
observer.on('departure', console.log)
const observedHafas = observe(hafasClient, observer, {departures: true})
// query data from HAFAS
observedHafas.departures('8011160') // Berlin Hbf
.then(console.log)
.catch(console.error)
observeHafasClient(hafas, emitter, watch)
hafas
must be a hafas-client
instance. emitter
must be an event emitter. watch
must be an object with one or more flags of the following list set to true
:
departures
:departure
events emitted on.departures()
arrivals
:arrival
events emitted on.arrivals()
journeys
:journey
events emitted on.journeys()
legs
:leg
events emitted on.journeys()
,.refreshJourney()
stopovers
:stopover
events emitted on.journeys()
,.refreshJourney()
,.trip()
trips
:trip
events emitted on.journeys()
,.refreshJourney()
,.trip()
movements
:movement
events emitted on.radar()
If you have a question or need support using observe-hafas-client
, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.