Drab: remote controlled frontend framework for Phoenix

web-frameworks
drab
frontend
javascript
phoenix

#462

I noticed in v0.10.0 Drab is set to require plug_cowboy 1.x – Drab (seemingly) worked for me with plug_cowboy 2.x. Did you find a reason to lock it down to 1.x?


#463

True, should be 1.0 or 2.0. 1.0 is for compatibility with the older versions of Phoenix. I will fix it.


#464

Hey @grych, I’m having issues again with connecting to the topics for broadcasting.

The fixes you originall implemented, that seemed to solve it, are now part of 0.9.3? Just checking they didnt slip out during a commit to the packages.

When i subscribe to a topic in the Drab Commander, should this show in the console logger that they are connecting to the topic, not the path?

here is my callback for onconnect :connected

def connected(socket) do
  subscribe(socket, same_topic(user.id))
end

But I only see logging that shows connection to the default path.

[info] JOIN "__drab:same_path:/user/dashboard" to Drab.Channel

Out of the blue, i seem to be having the same issues again, where broadcasting to a specific topic is going to multiple browsers that it should not (are not subscribed. e.g:

Drab.Element.broadcast_html(Drab.Core.same_topic(brand.id), "#auction", html)

Is there some way I can check that browsers are connected to specific topics properly? or see when that topic subscription changes. or have I got something wrong with how I am subscribing?

EDIT—
Using iex I can inspect the User socket after the onconnected callback. running that I can see this. Should i be able to see subscriptions to topics here?:

topic: "__drab:same_path:/user/dashboard",

EDIT –
I HAVE SOLVED THIS. I AM STUPID. That is all.

thanks again


#465

Dont even worry about me. it looks like i was actually broadcasting to the same topic.
Pro Tip, use unique names for the subscribing to topic, not user ids or numbers which could easily collide. hahah

kill me now.


#466

Actually this exact thing seems to still be happening :frowning:

User 1 logs in (subscribe to Topic 1)
User 2 logs in (subscribe to Topic 2)
Event is pushed to topic 1: ok
Event is pushed to topic 2: ok
User 1 refreshes browser
Event is pushed to Topic 1: Both users get the same data

As soon as I refresh one of those browser windows it seems to start pushing messages to both users.

Does 0.9.3 have the fixes in it?


#467

Yes, pls upgrade.


#468

Thanks.

I seem to be getting this error now. and I have no idea how to fix it.

function Phoenix.HTML.Engine.fetch_assign/2 is undefined or private

This is coming from a render function:
<%= render BonusWeb.Staff.OfferView, "_auction_js.html", active_offers: @active_offers, conn: @conn %>

I also get this error during compilation, which is all my drab pages…

warning: function Phoenix.HTML.Engine.fetch_assign/2 is undefined or private. Did you mean one of:

  * fetch_assign!/2

Found at 11 locations:
lib/bonus_web/templates/staff/dashboard/index.html.drab:1
lib/bonus_web/templates/staff/dashboard/index.html.drab:14
lib/bonus_web/templates/staff/dashboard/index.html.drab:103
lib/bonus_web/templates/staff/dashboard/index.html.drab:106
lib/bonus_web/templates/staff/offer/index.html.drab:1
lib/bonus_web/templates/staff/offer/index.html.drab:14
lib/bonus_web/templates/staff/offer/index.html.drab:26
lib/bonus_web/templates/staff/offer/index.html.drab:30
lib/bonus_web/templates/user/offer/show.html.drab:1
lib/bonus_web/templates/user/offer/show.html.drab:6
lib/bonus_web/templates/user/offer/show.html.drab:7

@grych as soon as I change my mix file to pull in that commit with the fix, it seems to start throwing this error.
Im using this to get the dep:
{:drab, github: "grych/drab", ref: "4ef09e8"},

plsss heellppp

I have tried upgrading everyting to phoenix 1.4, with drab 0.10.0 but i still get the same errrors.
As soon as i rename the index.html.drab file the page loads (without drab).


#469

Please see this issue here https://github.com/grych/drab/issues/180


#470

I dont understand how to lock phoenix_html version.
I have tried override, but it just keeps installing 2.13.1

{:phoenix_html, "~> 2.12", override: true}

I have tried things like == 2.12 but that never works either?
cant find any clear docs on how to do this.


#471

You may do something like

{:phoenix_html, "2.12.0"}

#472

just guessing but maybe a mix deps.unlock phoenix_html and then mix deps.get is needed?


#473

I am publishing v0.10.1 which contains fix for that issue (and many others)

It is Friday evening, and I am at the airport, publishing the release. What can possibly go wrong? :slight_smile: