den1k / re-frame-utils Goto Github PK
View Code? Open in Web Editor NEWRe-frame extensions
License: MIT License
Re-frame extensions
License: MIT License
Hello ๐
I think there is unexpected behavior regarding subscriptions disposal.
If you deref reagent atom outside of reagent rendering context, dependent subscription are not updated inside a watching list of parent subscription. So when you dispose!
it, dependent subs are not getting disposed.
Instead of using deref, should reagent.ratom/run be used which properly updates ratom watching list.
Here is the code snippet which demonstrates the issue:
(ns inject-sub-cofx
(:require [re-frame.core :refer [reg-sub subscribe]))
(reg-sub :bar
(fn [db]
(count db)))
(reg-sub :foo
(fn [_]
(subscribe [:bar]))
(fn [a _] a))
(comment
(def sub (subscribe [:foo]))
(deref sub)
(.-watching sub) ;; => nil
(reagent.ratom/dispose! sub)
(filter #(= :bar (get-in % [0 0 0])) @re-frame.subs/query->reaction) ; => ([[[:bar] []] #object[reagent.ratom.Reaction {:val 67}]]))
(reagent.ratom/run sub)
(.-watching sub) ;; => #js[#object[reagent.ratom.Reaction {:val 67}] #object[reagent.ratom.Reaction {:val 67}]]
(reagent.ratom/dispose! sub)
(filter #(= :bar (get-in % [0 0 0])) @re-frame.subs/query->reaction)) ;; => ()
I could make a PR if you think this is a good idea.
I also raised this question in clojurians slack, but didn't get any response.
When I add [vimsical/re-frame-utils "0.1.0"]
to project.clj lein deps
command fails as below:
$ lein deps
Could not find artifact vimsical:re-frame-utils:jar:0.1.0 in central (https://repo1.maven.org/maven2/)
Could not find artifact vimsical:re-frame-utils:jar:0.1.0 in clojars (https://repo.clojars.org/)
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
When I use [re-frame-utils "0.1.0"]
instead of [vimsical/re-frame-utils "0.1.0"]
everything is fine:
$ lein deps
Retrieving re-frame-utils/re-frame-utils/0.1.0/re-frame-utils-0.1.0.pom from clojars
Retrieving re-frame-utils/re-frame-utils/0.1.0/re-frame-utils-0.1.0.jar from clojars
The .jar
file contains a 6 megabyte directory called out
which in turn contains compiled sources to cljs.core, re-frame, reagent etc. This causes a lot of warnings when building projects with shadow-cljs
due to duplicate sources.
Expected behavior:
When I register a track over [:sub-a]
, I expect that that associated event is dispatched whenever any of the depedencies of [:sub-a]
is updated.
Actual behavior:
It works when I @(subscribe [:sub-a])
in a component.
As odd as it sounds, it seems that if I don't subscribe to [:sub-a]
additionaly to the track, the value under [:sub-a]
never gets updated.
Hi,
We're using your helpful library in production and would like to depend on a non-snapshot release. Would you consider bumping what's currently available as a non-snapshot release or is it still too alpha?
Thanks!
Gabriel
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.