Fork me on GitHub
#fulcro
<
2024-03-29
>
Rei15:03:18

Hey Tony and gangs. I have a question regarding custom remote. Following the section on creating a custom remote in the book, I've successfully created a custom remote that interacts with some other part of the app. Right now, everything is synced, I make a load!, transmit! calls some internal module that does some internal HTTP requests, then returns the result as a normal JSON object. Those internal modules can either return the full response body, or a promise. Since I'm looking into something non-blocking, how well does transmit! work with promises? Do you have any examples? I had a look into http-remote and it seems like the default fulcro-http-remote relies mostly on xhrio for all of its low-level request/response ops. Thanks in advance.

tony.kay15:03:38

xhrio is async. That’s why transmit gets “completion” functions.

tony.kay15:03:59

The whole point of a remote is to handle asynchrony 🙂

tony.kay15:03:26

so promises are fine. I’ve got a remote I defined that starts up and talks to a web worker, for example, which of course does async comms

tony.kay15:03:48

calling transact on that remote runs code in another thread 🙂

Rei15:03:28

Interesting. When I tried using promises I got some parsing errors which I thought it was because I wasn't allowed to do so. I'll have another look at the code. Thanks a lot 🙂

Rei15:03:55

Just to confirm, transmit! doesn't need to return anything, right?

tony.kay15:03:32

yeah, it isn’t promises that are your problem. You just are not transforming the data as expected. Correct. The return value of transmit is ignored

tony.kay15:03:05

transmit should start some async op, and then call the result-handler from the send-node when done.

tony.kay15:03:21

that value will then pass through the response middleware before being handed to Fulcro

Rei15:03:42

Awesome. Good to hear that it's my code that's not working properly 😄