How to map list of values in JS Commands pipeline to run commands on each value in list

Here is what I am trying to do:

def select_tab(tab, others) do "##{tab}-panel")
    |> fn js -> Enum.reduce(others, js, &unselect_tab/2) end
    |> JS.dispatch("tab:select", detail: %{tab: tab})

  defp unselect_tab(tab, js) do
    JS.hide(js, to: "##{tab}-panel")
    |> JS.dispatch("tab:unselect", detail: %{tab: tab})

However, I get an error on the tab:select dispatch saying it cannot accept the output of my best effort to map over the values in the list and apply commands.

Resolved the issue by using Kernel.then :man_facepalming: