rimmel
Version:
A Streams-Oriented UI library for the Rx.Observable Universe
17 lines (14 loc) • 650 B
JavaScript
import { catchError, of } from 'rxjs';
/**
* An error-catcher sink that displays a custom message when the underlying stream errors
* @param stream The original data or source stream
* @param handler A function that takes an error and returns a message
* @returns RMLTemplateExpression A template expression for the "innerHTML" attribute
* @example <div>${Catch(contentStream)}">
* @example <input value="${Catch(valueStream)}">
*/
const Catch = (stream, handler) => (stream.pipe?.(catchError((err) => of(handler(err)))))
?? (stream.catch?.((err) => handler(err)))
?? stream;
export { Catch };
//# sourceMappingURL=error-sink.js.map