macrobartfast 2020-10-15T00:35:59.109100Z

I just posted a lein re-frame template based question to #clojurescript if anyone has a moment to look at it.

furiel 2020-10-15T14:19:11.116700Z

Can someone help me with re-frisk ? I am learning re-frame and re-frisk helped me a lot during app development. There is this call: (re-frisk/enable) which puts the debug window into my application. Which I do not want to add in the production version, only for the development. Probably I need to add an if around enable, but I am not sure what should be the condition. Just guessing here: I have a figwheel.main based leiningen project: I have dev.cljs.edn and I can probably create a prod.cljs.edn too, which could carry build information. But me seems these are intended for figwheel.main, and I am not sure their content is available directly in my application. Is there any easy way to make (re-frisk/enable) conditional without creating a separate configuration file and read it's content?

andre 2020-10-28T19:15:39.262300Z

it's better to use :preloads [re-frisk.preload] in your dev config

furiel 2020-10-28T19:54:27.263100Z

@andre Thank you! Preload worked nicely.

p-himik 2020-10-15T14:22:34.116800Z

Check out re-frame.interop/debug-enabled?.

furiel 2020-10-15T14:34:42.117Z

Thank you for the idea! I am not entirely sure how this works, but according to the comment in the source code: the idea is that it defaults to true, but if I used advanced optimization, this will somehow turn to false automatically. Neat! I try this out.

furiel 2020-10-15T15:20:21.117200Z

No I misunderstood. I somehow need to set goog.DEBUG in the leiningen project file.

Oliver George 2020-10-15T22:34:02.119Z

The rise of asynchronous apis is a point of friction for re-frame. Possibly an inherant conflict of "state in memory" vs "state accessed via async".

Oliver George 2020-10-15T22:35:14.120300Z

Some kind of Promise friendly cofx might help. On react native the sqlite database and keystore apis are fast but promise based.

Oliver George 2020-10-15T22:36:49.121200Z

Reminds me of subs: signal + compute fns.

lilactown 2020-10-16T07:01:56.126700Z

unfortunately, re-frame's API, docs and general guidance encourage developers to use re-frame events as the language they use to implement their app, which makes common things like accessing a piece of data asynchronously tedious and error prone

lilactown 2020-10-16T07:06:12.127Z

promises are wonderful abstractions for a huge amount of use cases; they are composable (events: must build your own composition), they are completable and failable (events: must build your own completion and failure mechanisms), and have an identity (events: must build your own way of identifying between different occurrences)

lilactown 2020-10-16T07:06:38.127200Z

unfortunately they lack cancellation, which events can get you... if you build it and all of the other things 😄

p-himik 2020-10-16T07:09:19.127400Z

Absolutely agree.

Oliver George 2020-10-16T07:15:14.128500Z

Anything jump out as examples we can learn from?

p-himik 2020-10-16T07:22:55.128700Z

I've seem a few FSM libraries built [with support]for re-frame. Or just libraries that remove the need for some boilerplate. This one just yesterday: Others: - - There was another one but I didn't save it - I remember not liking it because it heavily relied on side-effects in event handlers. Should've still saved it though. But I haven't used any of them yet.

victorb 2020-10-16T10:48:58.129500Z

statecharts is an area I think we're still trying to find the right approach with, with regards to what level the APIs should act on. Definitely warrants more exploring though. Some more libs with statecharts+re-frame: • And finally, re-frame EP about general state machines, seems @mikethompson is leaning towards behavior trees instead of statecharts though, at least from what I gathered from a podcast he was in, talking about re-frame:

victorb 2020-10-16T10:49:41.129700Z

also, good general introduction to statecharts and how they can be beneficial:

p-himik 2020-10-16T11:13:08.130Z

Thanks for the links. Also, not sure if it's the same lib I was talking about but MaximGB/re-state definitely does dirty things.

p-himik 2020-10-16T11:13:28.130200Z

But maybe it's practicality vs purity in this case, not sure.

victorb 2020-10-16T11:23:05.130400Z

yeah, guess it's the same trade-off that re-frame is doing with the registers (or is it registrar?) where there is just one global one for practicalities sake. There is a doc in the re-frame repo somewhere talking about this but not finding it atm

p-himik 2020-10-15T22:38:43.121300Z

It's still possible to use things that re-frame offers in an async environment. But it will definitely have some boilerplate. But I'm not sure what you mean by "state accessed via async".

Oliver George 2020-10-15T22:39:59.121500Z

Perhaps "data sources" is a better word than "state" since that tends to imply the app-db in re-frame.

Oliver George 2020-10-15T22:41:33.121700Z

I agree it's possible... but if you're doing it in event handlers you're moving towards a more verbose version of the origial JS "callback hell". One option is to bundle things up as fx handlers. Another is the async-fx lib (sometimes).

Oliver George 2020-10-15T22:42:18.121900Z

I think cofx returning a promise and delays event execution until it resolves is an interesting idea.

p-himik 2020-10-15T22:44:05.122100Z

I understand the concept but I struggle to come up with an actual use case for that.

Oliver George 2020-10-15T22:44:56.122300Z

(Quick aside: I love your engagement on slack. You do good work)

p-himik 2020-10-15T22:45:12.122500Z

Heh, thanks. :)

Oliver George 2020-10-15T22:45:12.122700Z

Some examples I'm looking at right now. It's a React Natvie app.

Oliver George 2020-10-15T22:45:41.122900Z

I'm storing an api token in keystore. That means to use the token I need to pull it out via an async api.

Oliver George 2020-10-15T22:46:11.123100Z

So to avoid this in every handler which needs it I have choices 1. put it in app-db (keep in memory) 2. make all api calls reach into keystore directly (promise chain) 3. register two handlers the first to request data, the second to process

Oliver George 2020-10-15T22:46:19.123300Z

I went with option 1

Oliver George 2020-10-15T22:46:21.123500Z

Another example

Oliver George 2020-10-15T22:46:33.123700Z

I have an app with a database too large to hold in memory.

Oliver George 2020-10-15T22:46:41.123900Z

It's in sqlite which has an async api

Oliver George 2020-10-15T22:46:57.124100Z

to pull data out needed for a view I need to make one or more queries

Oliver George 2020-10-15T22:47:36.124300Z

So you need multiple handlers and perhaps an fx which to prepares data

Oliver George 2020-10-15T22:47:51.124500Z

That moves more logic into fx which makes them more complex.

Oliver George 2020-10-15T22:47:55.124700Z

that sort of thing.

p-himik 2020-10-15T22:49:45.125Z

Right, it makes it more clear, thanks.

p-himik 2020-10-15T22:51:42.125200Z

Actually, I just started to remember how at the very beginning of my path with re-frame I was reading about IndexedDB and I couldn't quite reconcile the two things in my mind.

Oliver George 2020-10-15T23:05:36.125400Z

I think there's a argument that we have the necessary building blocks and that the convenience of chaining promises comes at the price of being more complicated (complected) and thus more difficult to test and reason about.

Oliver George 2020-10-15T23:05:53.125600Z

Still think it'd be nice if re-frame was "closer" to data sources.

p-himik 2020-10-15T23:10:23.125800Z

Chaining promises is one thing. Using a plain promise as a data source is another. I would argue that the latter is acceptable.

Oliver George 2020-10-15T23:11:44.126Z

yep. that would cover the common case.