The emitter parameter pattern is a design technique for SPI (Service Provider Interface) contracts in libraries and frameworks. Instead of returning values from SPI methods, the framework passes an 'emitter' object as a parameter, and implementations call methods on it to produce output. This avoids problems with return-value-based designs: no need to allocate containers for single vs. multiple values, easier SPI evolution without breaking constructors, no concrete types exposed on the SPI surface, and flexibility for the framework to process emitted values in streaming or batched fashion. Real-world examples include Bean Validation 2.0's ValueExtractor and Debezium's ChangeRecordEmitter.

6m read timeFrom morling.dev
Post cover image

Sort: