A minimalistic ClojureScript interface to React.js
Oliver George 2021-05-26T08:06:39.016800Z

I’d like to set up a react component library and use it with my reagent app

Oliver George 2021-05-26T08:08:03.018300Z

Can anybody recommend build tooling. Is Babel enough? Rollup sounds about right, right?

Oliver George 2021-05-26T08:08:43.018800Z

I think I just need the basics really. Prefer not to invest heavily in fancy / complicated / transient stuff

Oliver George 2021-05-26T08:09:12.019400Z

(Having said that I am planning to use StorybookJS)

Oliver George 2021-05-26T08:12:07.020Z

(The react documentation points to other tools for component library setup)

Oliver George 2021-05-27T10:01:51.035300Z

Thanks for that link. Definitely ticks the boxes.

p-himik 2021-05-26T08:15:09.020100Z

You mean it has JSX files and no compiled JS files? If so, then I know only of this guide for shadow-cljs:

Quentin Le Guennec 2021-05-26T16:45:18.021900Z

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?

NoahTheDuke 2021-05-26T16:48:30.022100Z

lol second atom?

Quentin Le Guennec 2021-05-26T16:49:33.023200Z

Not sure if I'm being clear

NoahTheDuke 2021-05-26T16:50:31.024600Z

or make it a map: (atom {:initial true :value 0}) ... (swap! a #(if (:initial %) (assoc % :initial false :value 100) %))

Quentin Le Guennec 2021-05-26T16:51:01.024800Z


Quentin Le Guennec 2021-05-26T16:52:04.025100Z

Not sure if that would help

Quentin Le Guennec 2021-05-26T16:52:29.025600Z

I might just explain what I'm trying to do, it would be more explicit

Quentin Le Guennec 2021-05-26T16:53:50.027200Z

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

Quentin Le Guennec 2021-05-26T16:54:24.028Z

imperatively, fetch page, wait for the fetch to complete, print page on the screen, fetch page + 1, repeat

Quentin Le Guennec 2021-05-26T16:54:45.028200Z

"fetch" returns an atom

Quentin Le Guennec 2021-05-26T16:56:33.029Z

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.

Quentin Le Guennec 2021-05-26T16:57:55.029200Z

Does that make sense?

p-himik 2021-05-26T17:04:16.029300Z

Not very much, to be honest, Why does a fetch function return an atom in the first place?

Quentin Le Guennec 2021-05-26T17:04:42.029500Z

it returns the result of the fetch, either "loading", either data

p-himik 2021-05-26T17:07:09.029700Z

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.

Quentin Le Guennec 2021-05-26T17:10:10.029900Z

yeah, I'm aware that we extended the initial use of ratoms quite a lot

lilactown 2021-05-26T17:33:37.030800Z

using reactions for this is really difficult. my recommendation would be to use promises or some other method for composing these async operations

Quentin Le Guennec 2021-05-26T17:35:21.031200Z

I think I could get around it using track

emccue 2021-05-26T18:12:05.031600Z

@quentin.leguennec1 add a watch function that is memoized?

Quentin Le Guennec 2021-05-26T18:27:59.032100Z

@emccue I thought that was one of the uses of track

emccue 2021-05-26T18:28:23.032500Z

well track fires on any change

emccue 2021-05-26T18:28:43.033Z

if you want it to only ever fire once for a given state you need another box of state

emccue 2021-05-26T18:28:56.033200Z

hence memoizing the callback

Quentin Le Guennec 2021-05-26T18:30:18.033500Z

"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)."

Quentin Le Guennec 2021-05-26T18:30:23.033700Z


emccue 2021-05-26T18:33:48.034200Z

I thin that is more about saying that the function will only be triggered once per change

emccue 2021-05-26T18:33:54.034500Z

not per value ever encountered

Quentin Le Guennec 2021-05-26T18:37:55.034700Z

yeah, maybe

rgm 2021-05-26T20:51:11.035Z

I’m a bit late to this party but we put out our example reagent/re-frame leaflet component here … it’s not the most efficient thing in the world (it blows away all the markers every time, for example) but hopefully it’s enough to get started.