Can push be confirmed?

When pushing a message to channel, is it possible to get confirmation form server?

For example:

def handle_in("new:bus_location", msg, socket) do
      bus_id= msg["bus_id"] "new:bus_location buses:#{bus_id}"
      broadcast! socket, "new:bus_location", %{bus_id: bus_id, long: msg["long"], lat: msg["lat"]}

      {:noreply, socket}

is it possible to return {:ok, socket} ? then how would I listen for it after pushing the message?

The Phoenix Channel docs ( ) indicate that it is possible to return the tuple {:reply, my_reply_here, socket}.

Unfortunately I don’t know where to find the documentation for the javascript code, I’ve always just reached for the Programming Phoenix book. Hopefully someone can enlighten us both.

It is all in the phoenix javascript file at the top, decently documented. :slight_smile:

In the next Phoenix version it will be documented in the main phoenix docs too! :slight_smile:

But yes, returning a :reply instead of :noreply is the way to do it. The javascript API lets you listen for responses to a given message as well (something like channel.push(...).on("ok", fn).on("error", fn).on("timeout", fn) or something like that, all documented in the javascript file. :slight_smile:

1 Like

I have the v1.2.4 phoenix.js file bookmarked.

1 Like

9 posts were split to a new topic: Phoenix Channel JavaScript Client documentet at