I’d like to set up a react component library and use it with my reagent app
Can anybody recommend build tooling. Is Babel enough? Rollup sounds about right, right?
I think I just need the basics really. Prefer not to invest heavily in fancy / complicated / transient stuff
(Having said that I am planning to use StorybookJS)
(The react documentation points to other tools for component library setup)
Thanks for that link. Definitely ticks the boxes.
You mean it has JSX files and no compiled JS files? If so, then I know only of this guide for shadow-cljs: https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects
Hello, is there a way to execute a side effect once when an atom holds value A, and never again for subsequent resets of that atom at the same value A?
lol second atom?
Not sure if I'm being clear
or make it a map: (atom {:initial true :value 0}) ... (swap! a #(if (:initial %) (assoc % :initial false :value 100) %))
hmm
Not sure if that would help
I might just explain what I'm trying to do, it would be more explicit
I need to fetch n pages in some api, but I can fetch page + 1
only if page
is loaded and some side effect has been triggered that depends on page
imperatively, fetch page
, wait for the fetch to complete, print page
on the screen, fetch page + 1
, repeat
"fetch" returns an atom
so somehow, "fetch page + 1" is a reaction on "fetch page", but reacting on it would mean re-executing the side-effect, which is unwanted.
Does that make sense?
Not very much, to be honest, Why does a fetch function return an atom in the first place?
it returns the result of the fetch, either "loading", either data
I'm not entirely certain I completely understand what you're doing, but to me that, plus you saying that a reaction executes side-effects, seems like abusing Reagent ratoms/reactions system.
yeah, I'm aware that we extended the initial use of ratoms quite a lot
using reactions for this is really difficult. my recommendation would be to use promises or some other method for composing these async operations
I think I could get around it using track
@quentin.leguennec1 add a watch function that is memoized?
@emccue I thought that was one of the uses of track
well track fires on any change
if you want it to only ever fire once for a given state you need another box of state
hence memoizing the callback
"Every use of track with the same arguments will only result in one execution of the function. E.g the two uses of `@(r/track people)` in the example above will only result in one call to the people function (both initially, and when the state atom changes)."
from https://github.com/reagent-project/reagent/blob/master/doc/ManagingState.md
I thin that is more about saying that the function will only be triggered once per change
not per value ever encountered
yeah, maybe