Code Monkey home page Code Monkey logo

Comments (5)

MangelMaxime avatar MangelMaxime commented on July 22, 2024

Hello,

I think it's commented because when writing this library we didn't port the FormData type yet. Now it has been ported in Browser.XMLHttpRequest.

I don't know if we want a deps over that library or not for Fable.Fetch? cc @alfonsogarciacaro

For now, you can temporarily use dynamic typings using ? operator from Fable.Core.JsInterop body?formData

from fable-fetch.

alfonsogarciacaro avatar alfonsogarciacaro commented on July 22, 2024

Ah, you're right @MangelMaxime, I think that was the reason. Hmm, the main problem of Browser.XMLHttpRequest is it also pulls the Browser.Dom dependency, and I was thinking of making this package independent of it so it's a better fit for non-DOM environments like web workers or node (with a fetch polyfill).

Maybe we could just add the FormData definition to this package. It won't be compatible with Browser.XMLHttpRequest.FormData but hopefully it's not an issue.

Hmm, it seems FormData only makes sense in combination with HTMLFormElement so it would need a DOM dependency anyways 🤔

from fable-fetch.

alfonsogarciacaro avatar alfonsogarciacaro commented on July 22, 2024

Well, I guess the Browser.Dom dependency shouldn't do much harm even if you're in a non-DOM environment, so we could add FormData from Browser.XMLHttpRequest anyways. Thoughts?

from fable-fetch.

MangelMaxime avatar MangelMaxime commented on July 22, 2024

Hmm, it seems FormData only makes sense in combination with HTMLFormElement so it would need a DOM dependency anyways

I am pretty sure some people made it work even on node.js side for whatever reason ^^(speaking of raw JavaScript here).

Also, HTMLFormElement is an optional argument as you can see here

Well, I guess the Browser.Dom dependency shouldn't do much harm even if you're in a non-DOM environment, so we could add FormData from Browser.XMLHttpRequest anyways. Thoughts?

I suppose having it as a peer dependency is ok. In theory, the user should know that in a non-browser env he can't use all the Browser. modules same as in JavaScript.


Another solution I see is to move FormData to Browser.Blob add here the constructor without HTMLFormElement arguments. And then make Browser.XMLHttpRequest dependant over Browser.Blob and add in this package a version of the constructor with HTMLFormElement.

It seems to make sense to have it under Browser.Blob because of FormData.append accepting blob as one of the valid type. That's probably why we have value: obj in the definition.

The field's value. This can be a USVString or Blob (including subclasses such as File).

MDN

from fable-fetch.

alfonsogarciacaro avatar alfonsogarciacaro commented on July 22, 2024

That's a good idea, let's do that!

from fable-fetch.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.