Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async-flow de-registers itself multiple times, failing to do so #33

Open
Jarzka opened this issue Jan 28, 2021 · 1 comment
Open

async-flow de-registers itself multiple times, failing to do so #33

Jarzka opened this issue Jan 28, 2021 · 1 comment

Comments

@Jarzka
Copy link

Jarzka commented Jan 28, 2021

I have the following boot process:

(dispatch-sync [:boot])

(defn boot-flow
  [when-boot-done]
  {:id :boot-my-app
   :rules [{:when :seen-all-of?
            :events [::post-ids-loaded ::single-post-loaded]
            :dispatch when-boot-done}]})

(reg-event-fx
  :boot
  (fn [_ _]
    {:db state
     :async-flow (boot-flow [::boot-done])}))

With this, the boot process of my application works fine. The following things happen in the boot:

::post-ids-loaded is dispatched, once
::single-post-loaded is dispatched multiple times. This is not a bug since multiple posts are loaded in parallel. The boot process can be seen as done when at least one post have been loaded.

After the defined events have been seen once, the ::boot-done gets dispatched once.

However, when the ::boot-done is dispatched, I would like to halt the boot-my-app event . However, if I do this by setting :halt? true, the following error happens multiple times:

core.cljs:3936 re-frame: no :event handler registered for: {ns: null, name: "boot-my-app", fqn: "boot-my-app", _hash: 1520697945, cljs$lang$protocol_mask$partition0$: 2153775105, …}

What happens here? It seems that boot-my-app tries to de-register itself multiple times (as many times as ::single-post-loaded is dispatched, minus one since the first de-register works ok).

EDIT: It seems that this bug can be repeated with even more simple example:

{:id :boot-my-app
 :rules [{:when :seen?
          :events [::single-post-loaded]
          :dispatch [::boot-done]
          :halt? true}]}

This too causes multiple de-registers if ::single-post-loaded is dispached multiple times.

@hipitihop
Copy link
Contributor

@Jarzka Thanks for reporting. We will investigate and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants