Fork me on GitHub
#re-frame
<
2020-04-15
>
lsenjov22:04:00

I'm having difficulty getting a http request working as a co-effect. Any hints/examples anywhere? Or is the current way to trigger the dispatch in a callback?

dominicm23:04:42

@lsenjov you might be interested in https://github.com/Day8/re-frame-http-fx which packages it up for you

lsenjov23:04:26

I saw that, but that's the effect afterwards, not the co-effect of getting the data in the first place

lsenjov23:04:38

Unless I'm missing something?

mikethompson23:04:32

A coeffect is about "assembling" data so that an event handler can compute how an event will change the world

mikethompson23:04:50

So coeffects are a representation of the world as it is now - the moment the event happened.

mikethompson23:04:16

They are about obtaining sufficient information from the world, so the event handler can do its computations

mikethompson23:04:08

When you do an HTTP GET, that is an effect.

mikethompson23:04:36

It probably arises from the user hitting a button or something

mikethompson23:04:16

The event handler, on getting the event "user hit button" will want to initiate the HTTP GET ... that's the effect of the event

mikethompson23:04:13

Summary: you don't do HTTP GETs in coeffects. They happen in effects.

lsenjov23:04:38

Cool, thanks heaps for explaining

dpsutton23:04:28

I can see the confusion. What’s the difference between local storage state in a coeffect and database state in an effect besides locality