Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

feat: add demo#6

Draft
ubmit wants to merge 3 commits into
rescriptbr:masterfrom
ubmit:feat/add-demo
Draft

feat: add demo#6
ubmit wants to merge 3 commits into
rescriptbr:masterfrom
ubmit:feat/add-demo

Conversation

@ubmit
Copy link
Copy Markdown
Contributor

@ubmit ubmit commented Jul 19, 2020

This PR will add a demo

@ubmit
Copy link
Copy Markdown
Contributor Author

ubmit commented Jul 19, 2020

Which fetch function should be used here

fetch("/user", ~params={
  name,
  age,
})

I was trying to use bs-fetch, but the API seems different and it doesn't return the expected type either. Should I use something else? Also, I can fetch from basically any API, right? For demo purposes, a placeholder API like this https://jsonplaceholder.typicode.com/users should be fine I guess.

@ubmit
Copy link
Copy Markdown
Contributor Author

ubmit commented Jul 19, 2020

Another thing I've noticed is that there are form values somewhere on the README snippet. Should I use
https://github.com/Astrocoders/reform and get the values from there?

@fakenickels
Copy link
Copy Markdown
Member

I think it could be just a useState to keep the demo simpler! About the endpoint it could be a simple fastify server that we can spin up together with Webpack like in here https://github.com/fakenickels/es2077-course-slides/blob/master/forms-com-reason/server.js, everything needed for it's on this file and the only dependencies are fastify and fastify-cors

@vmarcosp
Copy link
Copy Markdown
Member

@GuilhermedeAndrade if u are using bs-fetch, you can use reason-promise to parse the result from Js.Promise.t to Promise.t, something like that:

let requestData = url => Fetch.fetch(url)|>Promise.Js.fromBsPromise|>Promise.Js.toResult;

[@react.component]
let make = () => {
  let (AsyncHook.{ state }, _) = AsyncHook.use((~cb)=> cb(() => requestData(url)));
  <div>
    <form>
    </form>
  </div>
};

@ubmit
Copy link
Copy Markdown
Contributor Author

ubmit commented Jul 20, 2020

@GuilhermedeAndrade if u are using bs-fetch, you can use reason-promise to parse the result from Js.Promise.t to Promise.t, something like that:

let requestData = url => Fetch.fetch(url)|>Promise.Js.fromBsPromise|>Promise.Js.toResult;

[@react.component]
let make = () => {
  let (AsyncHook.{ state }, _) = AsyncHook.use((~cb)=> cb(() => requestData(url)));
  <div>
    <form>
    </form>
  </div>
};

Thank you @vmarcosp! I'll keep this in mind once I start working on it again

@ubmit
Copy link
Copy Markdown
Contributor Author

ubmit commented Jul 26, 2020

@fakenickels @vmarcosp guys, I'd like to say that I'm sorry but I won't be able to keep working on this (at least not in the near future). I need to focus on some personal things right now. Since I'm still learning Reason, this PR is really challenging and, thus, time-consuming for me.

@ubmit ubmit closed this Jul 26, 2020
@vmarcosp
Copy link
Copy Markdown
Member

No problem! 👊

@fakenickels
Copy link
Copy Markdown
Member

Hey no worries at all! I'm going to reopen your PR so we can continue and merge!

@fakenickels fakenickels reopened this Jul 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants