Skip to content

Commit

Permalink
v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
grych committed Mar 15, 2017
1 parent d9e3b35 commit 09be292
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changes:
Changes:

## Bugs:
* Drab.Modal returns some sizzle on the second run, and do not wait, when debugging - all wrong while debugging
* all debugging function return stuff ater drab.modal, check flush after launching any modal
* Ignoring unmatched topic "drab:/drab" in DrabPoc.UserSocket

## Future
Expand Down
15 changes: 11 additions & 4 deletions lib/drab.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,17 @@ defmodule Drab do
Started Drab for /drab, handling events in DrabPoc.PageCommander
You may debug Drab functions in IEx by copy/paste the following:
socket = GenServer.call(pid("0.634.0"), :get_socket)
Examples:
Drab.Query.select(socket, :htmls, from: "h4")
Drab.Core.execjs(socket, "alert('hello from IEx!')")
import Drab.Core
import Drab.Query
import Drab.Modal
import Drab.Waiter
socket = GenServer.call(pid("0.634.0"), :get_socket)
Examples:
socket |> select(:htmls, from: "h4")
socket |> execjs("alert('hello from IEx!')")
socket |> alert("Title", "Sure?", buttons: [ok: "Azaliż", cancel: "Poniechaj"])
All you need to do is to copy/paste the line with `socket = ...` and now you can run Drab function directly
from IEx, observing the results on the running browser in the realtime.
Expand Down
16 changes: 10 additions & 6 deletions lib/drab/channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,21 @@ defmodule Drab.Channel do
# for debugging
GenServer.cast(socket.assigns.__drab_pid, {:update_socket, socket})
if IEx.started? do
commander = Drab.get_commander(socket)
modules = [Drab.Core] ++ commander.__drab__().modules
p = inspect(socket.assigns.__drab_pid)
pid_string = Regex.named_captures(~r/#PID<(?<pid>.*)>/, p) |> Map.get("pid")
Logger.debug """
Started Drab for #{socket.assigns.__url_path}, handling events in #{inspect(Drab.get_commander(socket))}
Started Drab for #{socket.assigns.__url_path}, handling events in #{inspect(commander)}
You may debug Drab functions in IEx by copy/paste the following:
socket = GenServer.call(pid("#{pid_string}"), :get_socket)
Examples:
Drab.Query.select(socket, :htmls, from: "h4")
Drab.Core.execjs(socket, "alert('hello from IEx!')")
#{Enum.map(modules, fn module -> "import #{inspect(module)}" end) |> Enum.join("\n")}
socket = GenServer.call(pid("#{pid_string}"), :get_socket)
Examples:
socket |> select(:htmls, from: "h4")
socket |> execjs("alert('hello from IEx!')")
socket |> alert("Title", "Sure?", buttons: [ok: "Azaliż", cancel: "Poniechaj"])
"""
end

Expand Down

0 comments on commit 09be292

Please sign in to comment.