Fork me on GitHub
#re-frame
<
2018-07-21
>
Garrett Hopper01:07:12

Has anyone here used Keechma? Thoughts? Specifically I like the lack of global state for usage in devcards, but I wanted to get others' opinions on its basic structure compared to re-frame.

sveri07:07:22

has anybody else experience with using a re-frame site from a mobile browser? I have weird behaviour like jumping cursor in inputs or its simply filling itself with strange text, presumably from autocorrect.

lepistane08:07:08

@ghopper check kee-frame i think that is amazing marriage between two

Garrett Hopper14:07:48

I did look at that, though it still has global state which is the main reason I'm looking elsewhere.

sveri12:07:39

Nobody here that uses a re-frame website on the handy browser?

sveri12:07:45

To expand a bit further on it. After a bit digging it is clear what happens. I have this input:

[:input {:on-change #(>evt [::set-username (h/get-value-of-event %)])}]
Now whenever I enter something on my mobile autocorrect is triggered and sends the event as autocorrect triggers the on-change event and fills it with the autocorrect suggestions. So I guess my question is if there is a way to prevent that? Edit this seems to happen only when I have a sub registered and display that:
:value (<sub [::get-username])

p-himik14:07:38

I'm not sure if that can help, but you can try using re-com. It handles many issues with HTML form inputs.

sveri14:07:54

I was thinking about it, but decided against it explicitly as they still warn they test it only on chrome and performance might suffer on different environments.

p-himik14:07:27

No need to use everything from it - you can just study how a particular component is implemented.

piotr-yuxuan13:07:55

How would you display a spinner waiting for a picture to load? Here is how I do it https://github.com/piotr-yuxuan/choose-a-new-phone/blob/db7145885695a86c15dc5e27f72e322c431decac/src/choose_a_new_phone/subs.cljs#L17-L31 I’d be very glad to discuss a better way 🙂

p-himik14:07:55

Line with (assoc-in @app-db [:available-resource? src] false) is not needed. How do you use the image after it's loaded? It does not appear to be used.

p-himik14:07:29

(by "not needed" I meant "has no effect")

p-himik14:07:56

Instead of a single sub that does literally everything, I would probably go with a single sub that dispatches an even to load an image. Also, I wouldn't use booleans as markers - I would just store a set of loaded URLs.

piotr-yuxuan14:07:18

Err, sorry, this typo has been fixed upstream. assoc-in is meant to be swap app-db assoc-in…

piotr-yuxuan14:07:58

When I create that element and give it a src, the browser (Firefox or Chrome) issues a GET. That’s the side-effect I want.

piotr-yuxuan14:07:53

Hum, you’re right, using a set is a better idea. Thanks 🙂

p-himik14:07:11

Yeah, I see that. By the lack of usage I meant that the resulting <img> is not used. Or do you later search for all <img> with a particular src?

piotr-yuxuan14:07:45

nope, I feel like it’d be suboptimal ^^ This temp <img> is only for the side-effect get. Then the subscription returns true or false so you can display the ‘real’, visible image when you’re sure it’s loaded.

piotr-yuxuan14:07:41

(I’ve updated the link in my first msg)

p-himik14:07:09

Not sure I follow. Do you use another <img> tag with the same src and only display it when the tmp <img> is loaded?

piotr-yuxuan14:07:47

yes. Does it sound weird? If you have a better idea, I’m in 🙂 anyway, thanks a lot for your comments

p-himik14:07:02

There's still no swap! in your link. 🙂

p-himik14:07:34

Oh wow, that's convoluted.

piotr-yuxuan14:07:51

no swap?, Aww, I guess Slack preview is bad.

p-himik14:07:12

I followed your link - Slack is not involved.

piotr-yuxuan14:07:52

^^' I do apologise!

p-himik14:07:52

What I think you should do is create a reagent, not re-frame, component. Like img-with-spinner or something. It would exist of a single :img - no need for a placeholder :div. It would have an explicit size so that the size is correct before the image is loaded, but initially its visibility would be set to hidden so that the space is still taken. The spinner would be rendered inside this component and got rid of when the img is loaded.

p-himik14:07:29

Another solution would be to split img and spinner - create something like img-with-feedback reagent component that would accept a on-loaded handler.

p-himik15:07:35

I'd go with the first solution if you don't need the info on available images in your app-db.

piotr-yuxuan00:07:01

Thanks again for your advices @U2FRKM4TW 🙂

👍 4