Skip to content

public-transport/observe-hafas-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

observe-hafas-client

Observe all departures/arrivals/etc. returned by a hafas-client instance.

npm version build status ISC-licensed chat with me on Gitter support me on Patreon

Installation

npm install observe-hafas-client

Usage

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)

API

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()

Contributing

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.