re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
borkdude 2020-06-20T10:59:51.471300Z

Something I'm working on for clj-kondo: user-level hooks for calls. E.g. for re-frame:

2020-06-20T11:00:30.471800Z

Very nice!

p-himik 2020-06-20T11:01:07.472500Z

Nice! Although, IIRC re-frame itself doesn't restrict the event IDs in any way - it can be a keyword without namespace, a symbol, a vector, whatever.

p-himik 2020-06-20T11:01:54.473Z

Ah, but given that it's user-level code, then it doesn't matter that much. Whatever a particular user decided to do.

borkdude 2020-06-20T11:03:45.473300Z

yeah, it gives the user choices about their own code style

borkdude 2020-06-20T11:04:01.473400Z

borkdude 2020-06-20T11:04:09.474Z

^ there the code is in its own file

2020-06-20T11:44:19.474900Z

Would it possible to make clj kondo be aware of all events?

2020-06-20T11:44:57.475900Z

Like using the event registry and check if the dispatch always sends a valid event?

2020-06-20T11:45:09.476400Z

Idem for subscriptions? (I am just asking)

borkdude 2020-06-20T11:47:32.477500Z

@neo2551 Theoretically one could write a hook for reg-event-fx and register all the keys into some state. And a hook for dispatch will then check the state. But this depends on the order of how the code is linted

borkdude 2020-06-20T11:48:13.477800Z

clj-kondo currently does not care about order of how files gets linted, it doesn't sort them in terms of namespace dependencies

borkdude 2020-06-20T11:50:08.478300Z

and I guess re-frame already emits warnings for this at runtime right?

borkdude 2020-06-20T11:55:42.479300Z

I guess if there is a hook at the end, then you can compare all registered events and all dispatched events and discover discrepancies

borkdude 2020-06-20T11:56:47.479800Z

but this only works when you lint all relevant files at the same time

borkdude 2020-06-20T11:58:07.480500Z

as of now, some hacky solution would be to use println or prn in the hooks for both dispatch and reg-event-fx and then write a little script to compare the outputs

2020-06-20T12:36:56.480800Z

Thanks :)

kitallis 2020-06-20T14:44:23.482800Z

Pretty new to re-frame, I’m trying to do something like https://github.com/nilenso/pencil.space/blob/lobby/client/cljs/src/game/events.cljs#L30. I’m trying to fire a series of side-effects when this event is dispatched. Two questions: 1. I assume I can’t assume any particular order for their firing? 2. How do I handle dispatching multiple fx like this which share the same key? Is this even a good idea?

p-himik 2020-06-20T14:47:00.483100Z

1. If you mean the effects in ::create-or-join, then yes, the order is not defined. If you really need some ordering, just chain events, i.e. use the :dispatch effect and in that event use the next effect. 2. You can either employ the event chaining described above or make the effect handler accept multiple sets of arguments.

kitallis 2020-06-20T14:49:29.483300Z

Hrm, I considered doing 1., but that was making my chained dispatches coupled with the next effect

kitallis 2020-06-20T14:51:14.483600Z

This seems super useful, I’m using a 100% namespaced kws and I often run into situations where my qualification errors aren’t correctly caught during build-time.

p-himik 2020-06-20T14:53:30.483900Z

Not sure I follow. You should end up with "private" events - you will not call dispatch on them from anywhere.

benny 2020-06-20T21:23:11.485700Z

using the renatal lein template (react native), i switched a few things around and my events aren’t firing when i dispatch from my repl. are there common pitfalls for this or is it a known issue by chance?