Change record status: 
Project: 
Introduced in branch: 
11.3.x
Introduced in version: 
11.3.0
Description: 

Introduce a new mergeWith()method in core/lib/Drupal/Core/Ajax/AjaxResponse.php.

A new mergeWith method has been added to the AjaxResponse class. This allows developers to another AjaxResponse into the current one.

Example

$response1 = new AjaxResponse();
$response2 = new AjaxResponse();

$response1->addCommand(new MessageCommand('Your changes have been saved.'));
$response2->addCommand(new MessageCommand('Your changes have been saved but saying it again.'));

/** @var \Drupal\Core\Ajax\AjaxResponse */
return $response1->mergeWith($response2);
Impacts: 
Module developers