Liam_or
Multiple hooks in Phoenix?
Is it still the case that you can only use one hook per Dom element in liveview? I know you can use one to delegate to others. But it would be way more modular and reusable if you can just have multiple hooks.
Liam ![]()
Most Liked Responses
marcandre
You may be confusing how to structure your JS side code into “libraries” (functions / classes / etc) and how to structure your hooks. Your hooks are the end-users of your libraries, not your libraries themselves.
I’d recommend to start with actual code and restructure later. You might get lost in remaining very abstract.
Good luck
benwilson512
Those hooks sound entirely too granular to me. I would think of a hook like a component. The hook should capture all of the behavior of that component that needs to happen at the JS level. A given DOM element simply is only one component, it doesn’t make sense to be multiple. Composition would be accomplished by a component that can contain other components.
Liam_or
That’s actually very helpful. Thank you ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #podcasts
- #code-sync
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








