Browse Source

stop search process

dxt 2 years ago
parent
commit
6c91da83b6
1 changed files with 16 additions and 0 deletions
  1. 16 0
      lib/comboSearch.ex

+ 16 - 0
lib/comboSearch.ex

@@ -38,6 +38,14 @@ defmodule NITRO.Combo.Search do
     end
   end
 
+  def keyUp(NITRO.comboKey(uid: uid, value: "stop")) do 
+    case :nitro_pi.pid(:async, "comboSearch#{uid}") do
+      [] -> []
+      pid ->
+        send pid, {:stop, uid, self()}
+    end
+  end
+
   def keyUp(NITRO.comboKey(uid: uid, value: value, dom: field, feed: feed, delegate: module)) do
     opts = [index: NITRO.Combo.index(module), field: field, delegate: module]
     comboContainer = :nitro.atom([:comboContainer, :nitro.to_list(field)])
@@ -90,6 +98,14 @@ defmodule NITRO.Combo.Search do
     end
   end
 
+  def proc({:stop, uid, ref}, NITRO.pi(state: state(opts: opts)) = pi) do
+    m  = Keyword.get(opts, :delegate, [])
+
+    send(ref, {:direct, NITRO.comboLoader(dom: uid, delegate: m, status: :finished)})
+
+    {:stop, :normal, pi}
+  end
+
   def proc({:filterComboValues, cmd, value0}, NITRO.pi(state: state(chunks: chunks, value: prev) = st) = pi) do
     state(uid: uid, feed: feed, reader: r, pid: pid, opts: opts) = st
     m     = Keyword.get(opts, :delegate, [])