Allow defining layout in callback function#1808
Open
mitchellhenke wants to merge 1 commit intonaymspace:developfrom
Open
Allow defining layout in callback function#1808mitchellhenke wants to merge 1 commit intonaymspace:developfrom
mitchellhenke wants to merge 1 commit intonaymspace:developfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
I was debugging some compile cycles in a Phoenix application, and noticed that
backpexwas part of the issue.The demo application has a good example of what I'm running into. If you run
mix xref graph --format cycles --label compile-connected, it reports that there is a compile cycle:This results in a change in any of the files recompiling all of the files, which usually means slower compile times during development in apps that use Backpex.
I'm not deeply familiar with Elixir compiler functionality, but my understanding is the reason for it is the
DemoWeb.Layoutsbecomes a compile dependency of the LiveViews when specified inuse Backpex.LiveResource.DemoWeb.Layoutsincludesuse DemoWeb, :htmlwhich ends up pulling in the router, etc.To continue the above example using the demo app, if you apply this patch to replace the layout option with the callback, the demo app no longer has a compile cycle:
I'm proposing allowing specifying the layout as a callback function to avoid the specific compile dependency between layouts and the LiveView. To avoid a breaking change, I've not removed the current option. I also haven't tried updating any guides, documentation, or similar, but am happy to if you're open to this change.