Skip to content

Commit

Permalink
[#257] Ref example: add disconnect and reconnect buttons (@danielcompton
Browse files Browse the repository at this point in the history
)
  • Loading branch information
danielcompton authored and ptaoussanis committed Aug 8, 2016
1 parent b793db1 commit 1f47b1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions example-project/src/example/client.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@
(->output! "Async broadcast loop now enabled")
(->output! "Async broadcast loop now disabled")))))))))

(when-let [target-el (.getElementById js/document "btn5")]
(.addEventListener target-el "click"
(fn [ev]
(->output! "Disconnecting")
(sente/chsk-disconnect! chsk))))

(when-let [target-el (.getElementById js/document "btn6")]
(.addEventListener target-el "click"
(fn [ev]
(->output! "Reconnecting")
(sente/chsk-reconnect! chsk))))

(when-let [target-el (.getElementById js/document "btn-login")]
(.addEventListener target-el "click"
(fn [ev]
Expand Down
3 changes: 3 additions & 0 deletions example-project/src/example/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
[:p
[:button#btn3 {:type "button"} "Test rapid server>user async pushes"]
[:button#btn4 {:type "button"} "Toggle server>user async broadcast push loop"]]
[:p
[:button#btn5 {:type "button"} "Disconnect"]
[:button#btn6 {:type "button"} "Reconnect"]]
;;
[:p [:strong "Step 2: "] " observe std-out (for server output) and below (for client output):"]
[:textarea#output {:style "width: 100%; height: 200px;"}]
Expand Down

0 comments on commit 1f47b1b

Please sign in to comment.