# onClose abstract method

S onClose(

1. void closeHandler()

)

Returns an equivalent stream with an additional close handler.

Close handlers are run when the close method is called on the stream, and are executed in the order they were added. All close handlers are run, even if earlier close handlers throw exceptions.

This is an intermediate operation.

## Example

    final stream = DartStream.of([1, 2, 3, 4, 5])
        .onClose(() => print('First handler'))
        .onClose(() => print('Second handler'));

    stream.close(); // Prints both messages

## Implementation

    S onClose(void Function() closeHandler);