<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="154280" data-post-id="154280">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="i-n-g-m-a-r" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  i-n-g-m-a-r
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Please don’t get me wrong, I absolutely love Elixir and Phoenix is awesome.<br>
Even to the point where I dislike having to work with anything else.</p>
<p>My questions regarding names, explicitness and feedback are about understanding what’s going on when something unexpected happens while working with Phoenix.<br>
I haven’t had a lot of experience with rendering and live views.<br>
Mostly I’ve used Absinthe and routers with mostly default settings.<br>
I didn’t study the inner workings of Phoenix a lot, I just went for it using a few howto’s on the internet.<br>
To me, not fully understanding exactly what is the purpose of many of the moving parts, things can get confusing.<br>
The docs suggest I shouldn’t have to worry about how stuff works, it just does.</p>
<p>Confusion is never about just one thing, it’s always about the constellation of things.<br>
It’s also about being allowed to do stuff that is confusing.</p>
<p>What should be the type of a session?<br>
Plug.Conn implements put_session/3 using Map.put/3, so probably session should be a map.<br>
So probably I shouldn’t be able to do: <code>live_render @conn, MyLiveView, session: false</code>.<br>
And this should probably not work: <code>def mount(false, socket), do: ...</code>.<br>
But is does.</p>
<p>And what happens when I don’t supply a :session options to live_render/3 ?<br>
I receive an empty map which is confusing because that’s not what my session looks like.<br>
When I don’t set a value it should be nil right?<br>
And is the :session option to live_render/3 an actual session?<br>
Or should I consider :session to be init_args that are named session in the context of a live view socket?<br>
Which would be more like assigns and would have little to do with my concept of sessions.<br>
Assigning init_args to the live view socket makes a lot of sense to me though.</p>
<p>What exactly are assigns?<br>
At first I thought it’s stuff you use inside templates with @.<br>
That’s what <code>render(conn, template, assigns)</code> suggests to me, assigns being a seperate argument.<br>
You have a conn, a template and some assigns (bound to the supplied template).<br>
So that would mean it’s not stuff you assign to a conn or a socket, but it is (and that’s awesome).<br>
Having a seperate assigns argument to render/3 makes assigns in the context of rendering templates seem unrelated to assigns in the context of a conn or a socket.<br>
It turns out that: <code>conn |&gt; assign(:some, :value) |&gt; render("index.html")</code> is equal to: <code>conn |&gt; render("index.html", some: :value)</code>.<br>
To me the former is very explicit and the latter is not helping me understand what’s actually happening, my assigns seem lost in space.<br>
So having a little helper argument to be able to write shorter code, makes me misinterpret the whole thing.</p>
<p>Assigns is not a Phoenix concept but it comes from Plug.conn.<br>
According to the docs: assigns - shared user data as a map.<br>
In my opinion assigns is an unfortunate name, why not call it user_data or shared_data.<br>
Phoenix kind of hides Plug, so it’s not necessary for me to worry about an unfortunate name like assigns.<br>
If it had been up to me, I would have probably implemented something like:<br>
<code>conn |&gt; assign(%Phoenix.UserData{some: :value})</code><br>
Forcing consumers to fetch any existing user_data and merge explicitly.<br>
I like the function name assign and the concept of assigning A to B.<br>
The implementation can match on A and make sure it becomes part of B in a meaningful way.<br>
It can perform validation and transformation and give me feedback.<br>
I could also <code>conn |&gt; assign(%Phoenix.SessionData{user_id: 1})</code> and pattern match on those types when passing values around.</p>
<p>Some things in Phoenix only become clear after a lot of investigation and gaining experience.<br>
Some of this has to do with names that could mean anything or suggest things that weren’t intended.<br>
And some of it has to do with lots of macro magic that is sometimes hard to follow.<br>
For the most part it’s just that Phoenix is a litte complex for novice users.</p>
<p>I’m writing this to give some feedback about my experiences as a novice Phoenix user.<br>
I would like Elixir and Phoenix to not only be awesome but also extremely popular.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="154280" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/argument-variable-naming-phoenix-socket-vs-phoenix-liveview-socket/27456/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-154280" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="154280"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>