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

Incorrect docs about the track function #487

Open
lucywang000 opened this issue Apr 13, 2020 · 0 comments
Open

Incorrect docs about the track function #487

lucywang000 opened this issue Apr 13, 2020 · 0 comments

Comments

@lucywang000
Copy link
Contributor

In the section The track function of the doc, it says:

The first argument to track should be a named function, i.e not an anonymous one.

But after playing with it a bit, i find it works well with anonymous functions. And from the code, it seems track is storing the cached results in the reagReactionCache attribute of the tracked function object, which shall not preclude the usage of anonymous functions.

(deftype Track [f args ^:mutable reaction]
  IDeref
  (-deref [this]
    (if-some [r reaction]
      (-deref r)
      (cached-reaction #(apply f args) f args this nil)))

(defn- cached-reaction [f ^clj o k ^clj obj destroy]
  (let [m (.-reagReactionCache o)
        m (if (nil? m) {} m)
        r (m k nil)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants