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

derivatives unavailable in will-unmount if the latter is placed after the former. #12

Open
livtanong opened this issue Jun 5, 2017 · 2 comments

Comments

@livtanong
Copy link
Contributor

Affects get-ref.

If I understand the source correctly, this is because the derivatives mixin always includes unmount code. You can call the custom will-unmount before the derivatives mixin, but as a project gets more complex, it could lead to code that is difficult to reason about. Something more explicit could be worth exploring.

I have two suggestions:

  1. Split the derivatives mixin into separate mount and unmount functions/vars
  2. Include an optional will-unmount hook into the d/drv mixin that will get called before the mixin executes its own unmount.
@martinklepsch
Copy link
Owner

martinklepsch commented Jun 6, 2017 via email

@livtanong
Copy link
Contributor Author

livtanong commented Jun 7, 2017

Sorry for taking so long, I've been quite busy these past few days.

(defcs sample
  <
  rum/reactive
  (d/drv :app/data)
  #?(:cljs
     {:will-mount (fn [state]
                    ;; we have access to derivatives
                    state)
      :will-unmount (fn [state]
                      ;; no access to derivatives
                      state)})
  [state]
  nil)

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