TwistingTwists
This is a thread to note down things/best practices encountered in LiveBeats App as I explore the source code.
https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/controllers/user_auth.ex#L29
Found this usage of rescue/1
I’ve been meaning to handle Ecto errors myself. So this comes in handy for next time.
Trending in Guides/Tuts
You probably already know that <span>{nil}</span> in a HEEX template produces <span> </span> when rendered. I fin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cvkmohan
Nice exercise @TwistingTwists
TwistingTwists
Who is current user in liveview app ? (even during redirects) More than just :fetch_current_user plug
live_beats/lib/live_beats_web/controllers/redirect_controller.ex at master · fly-apps/live_beats · GitHub
This has
conn.assigns.current_user- without worrying thatcurrent_usermight not exist.above is possible because of plug
:fetch_current_userhere → live_beats/lib/live_beats_web/controllers/redirect_controller.ex at master · fly-apps/live_beats · GitHubTwistingTwists
OneLiner For loop
https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/live/live_helpers.ex#L494
Never seen a for loop like this before.
Practical render_slots
live_beats/lib/live_beats_web/live/profile_live.ex at master · fly-apps/live_beats · GitHub
Message passing other component from present one - JS.push
live_beats/lib/live_beats_web/live/profile_live.ex at master · fly-apps/live_beats · GitHub
“switch_profile” is in
player_live.exlive_beats/lib/live_beats_web/live/player_live.ex at master · fly-apps/live_beats · GitHub
Pattern Matching - via two variables in function - elegant
matching if current user is same as profile user or any other case.
live_beats/lib/live_beats/accounts.ex at master · fly-apps/live_beats · GitHub
TwistingTwists
I think I should write @docs in a forked repo instead, no?
RudManusachi
First of all, thank you for this initiative!
I’d recommend to post a “permalink” to the line in the commit. That file was changed 7 hours ago. And looks like the link doesn’t point to the place you meant to.
dorgan
Protip: if you press Y while seeing a github file it replaces the url at the address bar with a permalink so you can copy that instead of scrolling and clicking copy permalink
TwistingTwists
Will take care.
https://github.com/TwistingTwists/live_beats/commit/36a775819ec2604cfe883eab6d5b198ffb3b7cd1
Added comments in this forked repo for consistency!
sergio
Excellent thread. Pinging @slouchpie so we can comb through this lots of good nuggets!
TwistingTwists
" Explain for loop : "
for a for {key, %{metas: metas}} <- presences, into: %{} dowhat does
into:do?as explained by @kartheek - from elixir-lang
must remember :
A comprehension is made of three parts: generators, filters, and collectables.kartheek
it collects into %{} in this case
The codefrom live_beats app is transforming presences - adding users and meta to every key in the presences. Final result will be
%{key1 => %{metas: <..>, user: <..> }, key2 => %{metas: <..>, user: <..> }}