A Sink is what a Source subscribes to. All events emitted by the source will be passed to the sink that has been given to the source.
The shape of a Sink is a function which takes an Event and distributes it to the onEvent function as described below. Sinks also implement the Disposable construct, and has all of the methods of the Disposable type, and can be treated as a Disposable. This is important as the way to stop a sink (and also unsubscribe the sources subscribed to the sink) is to dispose the sink itself. This also means that the way to cleanup or cancel some process when a Sink stops taking values (for example, when creating a custom Source), is to add a child to the Sink (as done on a disposable), which will then be called when the Sink is disposed. An example of this cancellation ability is say, cancelling a http request.
The sink constructor takes an onEvent function, which is called every time an event is received. When a sink is disposed, it will stop taking values and will ignore all subsequent events received. As well as this, when the sink is active and when the event received is a ThrowEvent or an EndEvent, then the sink will be disposed and then after this the onEvent function will called with the given event. If the onEvent function throws upon receiving an event, then the sink will immediately be disposed and the error will be thrown asynchronously in a setTimeout with delay zero.