Skip to content

Multiple controller for one element? #198

Answered by keithamus
jacob-carlborg asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the question @jacob-carlborg!

The short answer is no - not multiple per element; but the longer and probably more appropriate answer is: yes but with a bunch of different ways, depending on what fits.

You're right, Catalyst is heavily inspired by Stimulus, and their controllers sort of act like "mixins", applying a set of behaviours one-after-the-other. Catalyst leans heavily on Web Components in fact we want to ensure that Catalyst "is just web components".

Web Components allow for composition, but there's various patterns depending on what fits. You can use an array of class based patterns: inheritance chains, abstract classes, mixins. You can also compose with html-elements,…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jacob-carlborg
Comment options

Answer selected by jacob-carlborg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants