Listener

An listener attaches to a Fireproof database and runs a routing function on each change, sending the results to subscribers.

Constructor

new Listener(database, routingFn)

A Fireproof database Listener allows you to react to events in the database.

Parameters:
NameTypeDescription
databaseFireproof

The Fireproof database instance to index.

routingFnfunction

The routing function to apply to each entry in the database.

Methods

on(topic, subscriber) → {function}

Subscribe to a topic emitted by the event function.

Parameters:
NameTypeDescription
topicstring

The topic to subscribe to.

subscriberfunction

The function to call when the topic is emitted.

Returns:

A function to unsubscribe from the topic.

Type: 
function