registerStreamProtocol

abstract fun registerStreamProtocol(scheme: String, handler: (request: ProtocolRequest, callback: (response: Any) -> Unit) -> Unit): Boolean(source)

Whether the protocol was successfully registered

Registers a protocol of scheme that will send a stream as a response.

The usage is the same with registerFileProtocol, except that the callback should be called with either a ReadableStream object or an object that has the data property.

Example:

It is possible to pass any object that implements the readable stream API (emits data/end/error events). For example, here's how a file could be returned: