Snippets

Custom AJAX Commands

When changing the ajax responses with hook_ajax_render_alter(), you may sometimes want to add a custom ajax command. Drupal 8 actually supports a plugin-like functionality for it. This functionality needs to be served by a custom module and consists of 2 files - a src/Ajax class and a javascript file implementing the command.
Tags

Drupal Tempstore

Drupal 8 has a powerful mechanism to temporarily store data. Tempstore resembles storing data in session, and it also persists between the page reloads. There are two major types of storage that I ended up using: private tempstore and shared tempstore.