This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-23
Channels
- # announcements (2)
- # beginners (246)
- # boot-dev (1)
- # braveandtrue (3)
- # calva (13)
- # cider (26)
- # cljs-dev (6)
- # clojure (75)
- # clojure-finland (4)
- # clojure-germany (39)
- # clojure-italy (1)
- # clojure-mexico (1)
- # clojure-nl (14)
- # clojure-spec (61)
- # clojure-uk (104)
- # clojurescript (125)
- # cursive (20)
- # datomic (1)
- # emacs (2)
- # figwheel-main (91)
- # fulcro (29)
- # graphql (9)
- # jobs (3)
- # jobs-discuss (9)
- # juxt (13)
- # liberator (2)
- # luminus (1)
- # off-topic (15)
- # parinfer (8)
- # re-frame (70)
- # reagent (35)
- # reitit (24)
- # remote-jobs (5)
- # ring-swagger (3)
- # shadow-cljs (127)
- # spacemacs (34)
- # yada (6)
Okay so my next question: I’m very familiar with Redux and my preferred approach is to export “dumb” components alongside my store-connected components, primarily because I can very easily write stories for these. It seems like re-frame often advocates for using subs/ratoms in the component definition, doesn’t that make the devcards approach more difficult?
sure. why wouldn't you? (no clue about the re-frame stuff but devcards themselves work fine with shadow-cljs)
its just a CLJS lib. the fulcro
template generates a demo devcards config if you need one
@urbanslug figwheel has not been tied to leiningen for years
it has a lien plugin but people have used it from a script and the repl for a very long time
@jonathanj devcards renders any react elements that you provide it with
@bhauman Yeah, it seems like this issue leans much more to re-frame than devcards, specifically decisions around global state etc.
Some of the workarounds are things like iframes to segregate instances, a bit yuck.
not really worth it better off to create components that accept some kind of state and hand it to them
I think my approach would be to mimic my Redux workflow: Have a very dumb foo-view
component that has no subscriptions and have foo
be the re-frame-connected version.
no worries, I’m hoping that we can sometime figure out a way to make working with re-frame more straightforward
I got a whiff of trouble when there was no devcards profile for the re-frame lein template, so yeah it would be nice to have devcards and re-frame working together out of the box like that. One day.
@jonathanj I wish I had more time to make it happen. Stuck like this at the moment https://github.com/Day8/re-frame/blob/master/docs/EPs/002-ReframeInstances.md
@mikethompson glad to know this is on your radar 🙂
I’m very re-frame green, but my experience wrestling with this with React and Redux was that I didn’t actually want storybook to know anything about Redux. I don’t want to have to create a store, put some state in it, wrap my stories in providers, etc. just to have a component showcase.
All the callbacks are replaced with a storybook action()
that just logs something to the storybook, so nothing actually does anything it just confirms the contract the component (apparently?) adheres to.
I don’t know if some kind of optional (binding)
-type thing might be sufficient to wrap a re-frame component in some suitable local universe? Unfortunately I don’t know what Frame
s are, so meaningful commentary is probably at least one deep dive away.
I think the way I would want my re-frame devcards to work would be to have some kind of events log bundled into the card that corresponds to all the stuff the wrapped re-frame component dispatches. Maybe even listing what it’s subscribing to too.
@mikethompson Solution sketch #3 looks promising and we could create a devcards card that provides this frame id and displays the frame state
@jonathanj I would take some time and explore some of the things that devcards does, and recognize the differences from storybook. IE you can display the same component in different states on the same page and work on them in parallel. and many many more features that fundamentally depart from storybook
And it shouldn’t be difficult to create a component that does anything you want to do because in the end devcards simply renders react
I’d like to explore that, my time is a bit limited at the moment for it unfortunately.
I guess I’m just saying don’t come to it with too many preconceived strategies before giving it a try 😉
but thank you for pointing out storybook as I’m going to really give it a try to see what its bringing to the table
devcards is definitely much more flexible, which is great. Part of what is appealing about storybook is it’s narrowed focus and stronger commitment to that narrow focus (with things like the action logger, etc.) I think it ought to be pretty easy* to build something nicer than storybook with devcards, for pretty much all the reasons you’ve mentioned.
If it was possible to do something like (binding [*re-frame/global-app-db* (…)] (some-reframe-component …)])
(which I think is the ignorant-person’s version of Frame
s etc) you could trivially trap re-frame events and build a little self-contained IDE-esque devcard.
yeah bindings don’t work because effect handlers will probably escape the bindings at some point
Do someone know a library to use websocket from both sides (messages from server and from clients) ? ftravers/reframe-websocket only allow client -> server -> client
maybe because it was called lein figwheel? 😄 > I keep hearing this sentiment and I’m curious why folks think this
Hi all, what's the best way to deal with async API call and coeffects? I'm trying to write something similar to https://github.com/gothinkster/clojurescript-reframe-realworld-example-app/blob/master/src/conduit/db.cljs#L44-L50 ... in this code, getting a logged user from localStorage
involves a synchronous api call, we can just assoc
... In my case, I'm trying to get a user session via AWS Cognito JS SDK, that is async ... https://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-user-identity-pools-javascript-examples.html#using-amazon-cognito-identity-user-pools-javascript-example-retrieving-current-user
what i'm trying to do is to have some interceptor to check if the user is logged in and the session is valid .... if not, redirect to the login view ... is this the right approach to solve this? :thinking_face:
is it possible to call a reframe event handler directly? if so, how? i can dispatch, but that doesnt take the db as an argument. just for debugging*
@drewverlee not sure if this helps - https://github.com/Day8/re-frame/blob/v0.10.5/docs/Debugging-Event-Handlers.md ?
thanks ill take a look
before I go digging into the reframe internals to write my own reg-fx
function, i’m looking for a way for a registered fx to be handed two arguments, (fn [the-cofx-map the-app-db])
where currently they are only handed the cofx map. does something liket his already exist?
I have such an event: and I need it to run every x time at the core of my app. Basiclally client server sync. I'm making the request
(rf/reg-event-db
::get-some-data
(fn [{:keys [db]} _]
{:http-xhrio {:method :get
:uri url
:timeout 8000
:with-credentials false
:on-success [::add-data]
:on-failure [::api-request-error :get-data]}
:db (assoc db :loading? true)}))
Oh it says :response-format (ajax/json-response-format {:keywords? true}) ;; IMPORTANT!: You must provide this.
Edited: Are there any re-frame/reagent engineers that are looking for work? Someone who has a good grasp on react, front-end dev, and creating Server Side Rendering. There’s already a react template that we want to use and modify so as to not to start from scratch
I find re-frame-async-flow-fx
super useful. I was thinking it would be nice to be able to dispatch re-frame events with no expectation that they be handled. These events would just serve as a signal for asynchronous processes. I often find myself defining :action/success
handlers that don't do anything for this purpose. It would be convenient to be able to just add a ^:no-op
metadata to a dispatched event, and have it technically dispatched, but not throw a handling error. Does this make sense as a feature? Is there another pattern with re-frame-async-flow-fx
that I'm unaware of?