revati

revati

About attach_hook/4 after callback

Curently it supports :mount, :handle_params, :handle_event , and :handle_info and they are executed before main live view callback. Its all fine for cases, when one needs to validate/authenticate and so on, but if i need to do something after every handle_params, (to calculate active menu page, or just load extra data after main base bulk is loaded) i need to call it manually from every handle_params live view callback.

It would be nice if :mount, :handle_params, :handle_event , and :handle_info would also have after counterparts, for those cases.

Are there some mayor drawbacks for such approach?
How would you do it while there isnt such after hooks?

Most Liked

cmo

cmo

I find the assigning of nav and page title relevant to the page and/or data, so I have those functions in each liveview. Sometimes it is simply assigning constants and others it is more context aware. There is no context switching involved which I’m a fan of.

I’m not super keen on having something defined at the top of the file that will then change the output of functions down below :person_shrugging:

Last Post!

sodapopcan

sodapopcan

Components are always good for menu state. You can use attach_hook for handle_params to store the params or uri in state then pass that to a menu component which can do the calculation (so long as it’s a pure calculation, of course).

Where Next?

Popular in Discussions Top

ben-pr-p
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
nunobernardes99
Hi there Elixir friends :vulcan_salute: In a recent task I was on, I needed to check in two dates which of them is the maximum and which...
New
pillaiindu
I want to convert a Phoenix LiveView CRUD website to a CRUD mobile app. What do you think is the easiest way to do so?
New
cvkmohan
The upcoming Phoenix 1.6 release looks very interesting. Became a habit to watch the commits - and - what they are bringing in. phx.gen...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New
shishini
I think this twitter post and youtube video didn’t get as much attention as I hoped I am still new to Elixir, so can’t really judge ...
New

Other popular topics Top

hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement