-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mount multiple streams #53
base: master
Are you sure you want to change the base?
Conversation
</div> | ||
|
||
<div class="column"> | ||
<div class="box"> | ||
<h1 class="title has-text-centered">Tweet Type</h1> | ||
<div class="buttons are-large"> | ||
<button class="button is-light is-fullwidth is-outlined <%= is_selected("hourly_text", @hourly.filter.type, @hourly.filter.weight) %>" phx-click="hourly_text">Text</button> | ||
<button class="button is-light is-fullwidth is-outlined <%= is_selected("hourly_text", hourly.filter["type"], hourly.filter["weight"]) %>" phx-click="text" phx-value-stream="<%= stream %>" phx-value-interval="hourly" phx-value-filter="type">Text</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add phx-value-*
to send data to the phx-click
events.
For example phx-value-interval="hourly"
adds %{"interval" => "hourly"}
to the params
in the handle_event
callback.
I was able to remove a lot of duplication by sending specific values.
The The selection still needs work. |
here we go 🚀 |
data is getting overwritten in the callbacks, I'll see if i can figure out what's going on but no guarantees |
I can't figure out what's going on. There must be some callback that isn't aware of which stream's data it's getting or something. From staring at logging messages, the data accumulates as long as it's receiving new tweets of the same type... but when the tweet type changes it seems to reset. This doesn't happen when only one stream is active. |
<div> | ||
<p class="heading">Stream</p> | ||
<p class="title"><%= String.upcase(stream) %></p> | ||
<%= if Enum.count(@streams) > 0 do %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pattern match and avoid the count here.
if @streams == [] do
# no streams
else
# show stats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The match?/2
macro is an alternative to the above. Whatever reads better to you.
if match?([], @streams) do
I'm pretty sure I know what's going on here. There's no bug, LiveView is working as expected 😀 LiveView updates whenever a key is assigned to the socket. With the current changes all the data is stored under the I'm going to have to do some more research on LiveView and figure out what we can do here. |
I'm gonna try out another approach (fancy liveview stuff) on another branch. Depending on how that goes, we may not use this branch. |
Sounds good man |
closes #13