We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
phoenix_live_view changelog
Hey there, awesome devs! We've got some nifty updates and tweaks to make your coding life a bit smoother. Check out the latest changes:
🛠️ Improvements
Enhanced Documentation for Live Components
We've spruced up the docs for the mount
and update
callbacks in Phoenix.LiveComponent
! Now it's crystal clear that the component’s socket
doesn’t inherit the parent's assigns and that changes to it won’t affect the parent LiveView. Plus, we’ve detailed the expected return values for both c:mount/1
and c:update/2
. Dive in and get those live components rocking! 🚀
Refined on_mount
Macro to Reduce Compile Dependencies
The on_mount
macro just got smarter! We’ve refactored it to handle arguments more flexibly, reducing unnecessary compile-time dependencies. A new private function, expand_literals
, ensures that only the essentials are expanded. Your compile times should be a tad quicker now! ⚡️
Clarified JS Transition Durations
We’ve added a shiny new example to the lib/phoenix_live_view/js.ex
file. Now, it’s easier to see how a duration-300
CSS class translates to a time: 300
milliseconds in JS transitions. No more guessing games—just smooth animations! 🎨
Keep on coding and stay awesome! 💻✨
Included Commits
This commit modifies the lib/phoenix_live_view/js.ex
file within the Phoenix LiveView framework to clarify the relationship between the transition duration specified in a CSS class and a time parameter in the JS transition function. Specifically, it adds an example that demonstrates how the CSS class duration-300
corresponds to a transition time of 300 milliseconds.
The change includes an additional example in the documentation, where a div element is mounted with a transition that combines easing and opacity effects, explicitly stating that duration-300 milliseconds
matches time: 300 milliseconds
. This enhancement aims to improve the clarity and usability of the transition functionality for developers using the framework.
Files changed
- lib/phoenix_live_view/js.ex
This commit enhances the documentation for the mount
and update
callbacks in the Phoenix.LiveComponent
module of the Phoenix framework. It clarifies the distinction between the socket
received by the c:mount/1
function and the parent LiveView's socket
, emphasizing that the component's socket
does not inherit the parent's assigns and that modifications to it will not affect the parent LiveView. The documentation also specifies that the c:update/2
function is called with only the new assigns passed to live_component/1
, while any pre-existing assigns can be accessed through socket.assigns
.
Additionally, the commit outlines the expected return values for both c:mount/1
and c:update/2
, stating that they must return a tuple with :ok
as the first element and the updated socket
as the second. Overall, these improvements aim to provide clearer guidance for developers working with live components, ensuring they understand the lifecycle and behavior of component state management within the framework.
Files changed
- lib/phoenix_live_component.ex
The commit titled "Avoid compile dependency in some cases on on_mount
" introduces modifications to the on_mount
macro in the Phoenix.LiveView
module. The primary change involves a refactoring of how the macro handles its arguments. Instead of always passing the entire mod_or_mod_arg
to the expand_literals
function, the new implementation allows for the possibility of expanding only the first element of the tuple if it is structured as {mod, arg}
. This change enhances flexibility and reduces unnecessary compile-time dependencies.
Additionally, the commit adds a new private function, expand_literals
, which checks if the provided Abstract Syntax Tree (AST) is a quoted literal. If it is, the function applies Macro.prewalk
to expand the aliases within the AST. This refactoring not only streamlines the logic within the on_mount
macro but also improves the overall efficiency of the code by minimizing the compile-time requirements in certain scenarios.
Files changed
- lib/phoenix_live_view.ex