- Issue created by @fathershawn
- First commit to issue fork.
- ๐บ๐ธUnited States fathershawn New York
All green is super - nice work! This is direction really simplifies the changes in big_pipe.js and thatโs a real plus.
Because bigPipe as we have it re-uses existing javascript from the ajax system, to remove the ajax system we need to replace that.
@nod_ had this list in a Slack discussion:We need the equivalent of those 3 commands to implement bigpipe
- use Drupal\Core\Ajax\MessageCommand;
- use Drupal\Core\Ajax\RedirectCommand;
- use Drupal\Core\Ajax\ReplaceCommand;
- Add_css/add_js and the settings but thatโs mostly available already
I think we need to identify the pieces of this list that htmx is not going to do, and implement those in general scope. Then the items that htmx does just fine in an ajax context, we need to have as helper methods in big_pipe.js and leverage the htmx api where we can.
I'm going to take them in order.
MessageCommand
In the ajax context, I would have implimented this in HTMX using a header and a custom event handler that calls ourDrupal.Message
function. This is actually the example in the trigger headers documentation.HX-Trigger: {"showMessage":{"level" : "info", "message" : "Here Is A Message"}}
One thing that
Drupal.Message
does client-side is determine the selector for the message container. If there is a way to do that server-side then this could also be implemented as an extra out-of-band swap on the response without any additional javascript.We do need a helper method for this that we can use in big_pipe though.
RedirectCommand
HTMX has both the HX-Redirect and HX-Location response headers. We don't have a response so we need a function for that in bigPipe.ReplaceCommand
We also just need the bigPipe use case for bigPipe. This is one of the core competencies of htmx in an ajax request context.addCSS and addJS
In the ajax context using htmx, these feel like out of band swaps as well. - ๐บ๐ธUnited States fathershawn New York
fathershawn โ changed the visibility of the branch 3526267-bigpipe-with-htmx to hidden.
- ๐บ๐ธUnited States fathershawn New York
Here's an MR into @nod_'s branch moving the bigPipe command JS into bigPipe scope. It looks like the test setup scripts don't like MR's into a feature branch. The tests generally pass locally - 2 failures involving noJS exceptions. Not sure if that's a false negative as all of these changes are in JS.
If this is an acceptable direction then I think the next level of refactoring is to create the needed bigPipe Command classes to replace the AjaxCommands and update BigPipe.php to work without the Ajax API classes.