Skip to content

Commit

Permalink
feat: Add connected-interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Jan 29, 2024
1 parent 0331cdb commit e349725
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/elin/component/interceptor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
(def ^:private default-interceptors
[e.i.connect/port-auto-detecting-interceptor
e.i.connect/output-channel-interceptor
e.i.connect/connected-interceptor
e.i.output/print-output-interceptor
e.i.nrepl/eval-ns-interceptor
e.i.nrepl/normalize-path-interceptor
Expand Down
13 changes: 11 additions & 2 deletions src/elin/interceptor/connect.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@
(def output-channel-interceptor
{:name ::output-channel-interceptor
:kind e.c.interceptor/connect
:leave (fn [{:as ctx :elin/keys [interceptor] :keys [elin client]}]
:leave (fn [{:as ctx :keys [elin client]}]
(when client
(async/go-loop []
(let [{:component/keys [writer]} elin
(let [{:component/keys [writer interceptor]} elin
ch (get-in client [:connection :output-channel])
output (async/<! ch)]
(when output
(->> {:writer writer :output output}
(e.p.interceptor/execute interceptor e.c.interceptor/output))
(recur)))))
ctx)})

(def connected-interceptor
{:name ::connected-interceptor
:kind e.c.interceptor/connect
:leave (fn [{:as ctx :keys [elin]}]
(let [{:component/keys [interceptor]} elin]
(->> {:elin elin :autocmd-type "BufEnter"}
(e.p.interceptor/execute interceptor e.c.interceptor/autocmd)))
ctx)})

0 comments on commit e349725

Please sign in to comment.