-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Compatibility with new Fable.React #34
Conversation
I do like the distinction between About the new Because before we could do Another question about the naming is: is there any benefits for adding I know that you added
This will limit the API changes and make it cleaner to use prefixed API. |
More to the point, I agree with Maxime. |
These are very good points, thank you! Sorry for the mess, but for a more in-depth discussion about the names in the new Fable.Browser packages I've opened a new issue 😄 fable-compiler/fable-browser#1 |
❤️ Finally! having to always open these was always confusing and distracting: one namespace has types so I need Although I agree with @MangelMaxime that IMO that the following is much cleaner:
Library code: namespace Fable.Browser
[<AutoOpen>]
module Browser =
type Document =
let getElementById : elementId: string -> HTMLElement
let [<Global>] document: Document = jsNative Here is how the consuming code looks like: open Fable.Browser
let rootElem = document.getElementById "root"
console.log("hello from Fable") So much easier to think about, you need to work with the dom? just open the browser namespace and you are good to go Another thing I am not sure of is whether to add the types in a different module (e.g. namespace Fable.Browser
[<RequireQualifiedAccess>]
module Types =
type Document =
let getElementById : elementId: string -> HTMLElement
[<AutoOpen>]
module Browser =
let [<Global>] document: Types.Document = jsNative this way, if the consumer code wants to use explicit type signatures, they won't have to open yet another namespace but instead, qualify the type name with prefix open Fable.Browser
// qualify type names if you need them
let init (doc: Types.Document) : unit =
let root = doc.getElementById "root"
root.innerHTML <- "Hello from F#"
init document // document is available since Browser is auto opened the nice about this, is that if the user uses many binding libraries with open Fable.React
open Fable.Brower
// use types from Fable.React
let makeStyle (x: Types.ICSSProp list) =
// do stuff
// qualify type names from Fable.Browser
let init (doc: Types.Document) : unit =
let root = doc.getElementById "root"
root.innerHTML <- "Hello from F#" What do you think @alfonsogarciacaro @MangelMaxime ?? |
We should keep the discussion in fable-compiler/fable-browser#1. This PR is about |
Superseded by #37 |
Following discussions in fable-compiler/fable-import#73, I've started to split Fable.Import.Browser. And I thought it could be a good opportunity to drop the
Fable.Import
(andFable.Helpers
) prefix and have smaller packages in their own repository for easier maintenance. In Fable.React, I'm dropping most of the bindings generated with ts2fable and restructuring the files.I thought it would be possible to have namespace/module alias to minimize the number of changes, but it seems these alias cannot be made public. So for now I'm just trying to raise a message with the new name. Does anybody know a better way?
What do you think? Does this change make sense (see also this discussion) or should we keep the namespaces to prevent too many breaking changes?
@ncave @et1975 @MangelMaxime @Zaid-Ajaj @Nhowka @nojaf @forki