I have completely fallen in love with phoenix channels and I am trying to learn as much as I can about them .
I am wondering why I cant pass a empty map as a parameter in the broadcast/3 , broadcast_from/3 and push/3 from the channel module.
What I am trying to achieve is sending a message to the client to run a specific function on the clients on the channel.
I just want the function to run on the client not to pass any data through the channel.
also is this a good use of channels ? or am I traversing the Atlantic in a bucket ?
I`m setting up a real time leaderboard for some activities for my kids this Christmas and I am refreshing the leaderbord on the :create , :update, and :edit functions in my controller
in my mind it was the quickest solution to send a call to the js location.reload(); function.
but I get the feeling I am missing something as I see from other sources that they prefer to add the data in the payload is there any pro/con I should know about. I am a complete newbie on both js and html.
I think you can broadcast from inside of your controllers. Something like YourAppName.Endpoint.broadcast(topic, event, msg) (docs) should do the trick. msg would be the new data (or the difference), which you can append (or do whatever you want) to the leaderboard with some javascript, instead of using location.reload(). With location.reload() you might end up requesting some unnecessary information (like all of html) every time something in the leaderboard changes.