by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    robertj
    @robkuz
    OK. cool. thx for the suggestion
    Aleksander Spro
    @projecteon
    I would highly advice against using 2 css frameworks together. It will also increase bundle size considerably.
    Balinth
    @Balinth
    While trying out the VS Code Debugger for Chrome thingy, for some reason starting the server from the debug window changes the base path where the server looks for additional files (eg appsettings.json) versus building from fake (even with a new SAFE template, and using it's fake script, versus the provided "Debug SAFE application" debug target. Where or what kind of setting should I look for to specify this base path?
    as far as I could tell, starting from the debugger still runs the fake build -t run command in the end
    Florian Verdonck
    @nojaf
    Hey @MangelMaxime

    Thoth.Json decode question: How would I decode

    type Node =
        { Type: string
          Range: Range option
          Properties: Map<string, obj>
          Childs: Node list }

    The Properties, I don't really care what is in the object. I only need to display it in my view.
    It could look like:

        {
          "Type": "SynModuleOrNamespace.AnonModule",
          "Range": {
            "StartLine": 1,
            "StartCol": 0,
            "EndLine": 1,
            "EndCol": 0
          },
          "Properties": {
            "isModule": "AnonModule",
            "isRecursive": false,
            "longIdent": [
              {
                "Ident": "Script",
                "Range": {
                  "StartLine": 1,
                  "StartCol": 0,
                  "EndLine": 1,
                  "EndCol": 0
                }
              }
            ]
          },
          "Childs": []
        }
    Florian Verdonck
    @nojaf
    Found a workaround:
    let decodeKeyValue : Decoder<obj> = fun _key jsonValue -> Ok jsonValue
    Pieter Bryon
    @pbryon
    Hi guys. I'm not sure this is the place to ask and I apologise upfront if the answer is in the docs somewhere but I couldn't find it.
    When testing my (first) SAFE app, I keep getting connection refused WebSocket errors when running it. What am I missing?
    Cody Johnson
    @Shmew
    do you have a dev server proxy setup in your webpack.config.js?
    Pieter Bryon
    @pbryon
    The standard version that came with the SAFE template, I think:
    devServerPort: 8080,
        // When using webpack-dev-server, you may need to redirect some calls
        // to a external API server. See https://webpack.js.org/configuration/dev-server/#devserver-proxy
        devServerProxy: {
            // redirect requests that start with /api/* to the server on port 8085
            '/api/*': {
                target: 'http://localhost:' + (process.env.SERVER_PROXY_PORT || "8085"),
                   changeOrigin: true
               },
            // redirect websocket requests that start with /socket/* to the server on the port 8085
            '/socket/*': {
                target: 'http://localhost:' + (process.env.SERVER_PROXY_PORT || "8085"),
                ws: true
               }
           },
    Cody Johnson
    @Shmew
    that's pretty much how mine is setup, except I also have changeOrigin: true on my socket proxy, might want to try that as well
    Pieter Bryon
    @pbryon
    @Shmew that didn't do the trick. I'm also getting uncaught exception: SocketProtocolError: Socket hung up from scclientsocket.js, if that helps

    and:

    {
      "name": "BadConnectionError",
      "message": "Event 'login' was aborted due to a bad connection",
      "type": "connectAbort",
      "stack": "BadConnectionError@webpack-internal:///./node_modules/sc-errors/index.js:182:19\nSCClientSocket.prototype._abortAllPendingEventsDueToBadConnection@webpack-internal:///./node_modules/socketcluster-client/lib/scclientsocket.js:586:19\nSCClientSocket.prototype._onSCClose@webpack-internal:///./node_modules/socketcluster-client/lib/scclientsocket.js:609:8\nSCClientSocket.prototype.open/<@webpack-internal:///./node_modules/socketcluster-client/lib/scclientsocket.js:297:12\nEmitter.prototype.emit@webpack-internal:///./node_modules/component-emitter/index.js:133:20\nSCTransport.prototype._onClose@webpack-internal:///./node_modules/socketcluster-client/lib/sctransport.js:217:28\nSCTransport/wsSocket.onerror@webpack-internal:///./node_modules/socketcluster-client/lib/sctransport.js:81:12\n"
    }

    from devtools.js

    Cody Johnson
    @Shmew
    only other advice I have is to try these:
    devServer: {
            ...
            inline: true,
            historyApiFallback: true,
            ...
        },
    I use Elmish.Bridge, so I can't help you any further than that if it doesn't work.
    Pieter Bryon
    @pbryon
    thanks for trying!
    Cody Johnson
    @Shmew
    np
    gl
    Pieter Bryon
    @pbryon
    thanks
    njlr
    @njlr
    Can Thoth.Json decode an plain-old-javascript object to give something like a runtime schema checker?
    Florian Verdonck
    @nojaf
    Yes, I believe you have Decode.fromObject
    Or it is called .from value
    Maxime Mangel
    @MangelMaxime

    @njlr Yes it can and it's actually how Thoth.Json is working :)

    Soure code

        let fromValue (path : string) (decoder : Decoder<'T>) =
            fun value ->
                match decoder path value with
                | Ok success ->
                    Ok success
                | Error error ->
                    Error (errorToString error)
    
        let fromString (decoder : Decoder<'T>) =
            fun value ->
                try
                   let json = JS.JSON.parse value
                   fromValue "$" decoder json
                with
                    | ex when Helpers.isSyntaxError ex ->
                        Error("Given an invalid JSON: " + ex.Message)

    See how fromString use fromValue by passing the result of JS.JSON.parse which gives you an "obj".

    This is also how Nacara use Thoth.Json to explore the global configuration and the configuration of a page etc. Mentioning that to say that's supported
    Ben Collins
    @aggieben
    Trying to work through the elmish book and found that the elmish-getting-started project fails somewhere in Fable build:
    image.png
    totally newbie question: how do we troubleshoot?
    Ben Collins
    @aggieben
    looks like maybe the Fable.Elmish.3.0.0 project in .fable is expecting a Paket.Restore.targets file that doesn't exist?
    njlr
    @njlr
    @MangelMaxime Perfect! Turns out I can remove a redundant JSON.parse(JSON.stringify(x) from my app!
    Ben Collins
    @aggieben
    Opened this issue over at Zaid's repo: Zaid-Ajaj/elmish-getting-started#2
    Peter Keše
    @pkese
    I'm banging my head on trying to understand async code
    All I want is to cache an async result (wrap it in lazy) and then use it in several places (but accessing the server just once)
    But I'm finding out that that the async code is being executed multiple times:
    let asyncData = lazy (async { return fetchSomeUrl () })
    let getOrFetch = asyncData.Force
    ...then when I intialize my state, I add initial command
    state, Cmd.OfAsync.either getOrFetch () ConsumeServerData ConsumeServerError
    Cody Johnson
    @Shmew
    @pkese I'd recommend just putting the result in local storage, and then when making calls it can check if it already exists and if so, not make the call
    Peter Keše
    @pkese
    @Shmew thanks for suggestion.
    There seems to be a mismatch between my conceptual map of the world (i.e. how I think async works) and how async really works. I can of course do a workaround, but that's just a way to avoid understanding what's going on.
    And then I'll get bitten again next time I try to use async.
    njlr
    @njlr
    I think you are caching the construction of the async, not the execution of the async?
    Peter Keše
    @pkese
    How should I change the code to cache the execution?
    njlr
    @njlr
    I would hide a mutable somewhere
    open Fable.Core
    
    let computation = async {
      printfn "Computing... "
      return 42
    }
    
    let cache workflow = 
      let mutable cachedValue = None
      async {
        match cachedValue with
        | Some x -> return x
        | None -> 
          let! x = workflow
          cachedValue <- Some x
          return x
      }
    
    Async.StartAsPromise (async {
      let cachedComputation = cache computation
    
      for i in 0..10 do
        let! x = cachedComputation
        printfn "%i" x
    
      printfn "Done. "
    })
    |> ignore
    sorry for formatting..
    Peter Keše
    @pkese
    Yes, I guess I'll do that in the end
    Cody Johnson
    @Shmew
    I have a file in my web app project that isn't used in the actual application, but webpack includes it in the bundle and apparently breaks the app because of it. Is there a way to make sure fable doesn't include a file in my webpack.config.js?
    The file is completely self-contained, doesn't reference any of the files or vice versa
    Damian Reeves
    @DamianReeves
    Hey… is there any good example of building a node commandline application with fable (outside of the node samples in fable2-samples.
    Cody Johnson
    @Shmew
    Hey @MangelMaxime in my webpack.config.js I'm setting this option: define: isProduction ? ['WEBPACK'] : ['DEBUG','WEBPACK'] but I'm having trouble with doing <Compile Include="SomeFile.fs" Condition="$(WEBPACK) == True" /> I've tried a few different variations, but the best I've been able to do is essentially have it be != True which works kinda, but it's annoying never having my file in my project. Do you know what I'm doing wrong?
    Ilja Nosik
    @inosik
    @DamianReeves ts2fable is a Node application. Are you looking for something in particular?
    Ilja Nosik
    @inosik
    @Shmew Are you sure that the file isn't actually used? The tree-shaking should take care of that, I think. Or maybe your configuration is incomplete?
    Anyways, the values you configure in the define option are compiler constants, not MSBuild properties. You can set the WEBPACK environment variable to True, which MSBuild will then use as a property and hopefully evaluate your condition correctly.
    I wouldn't recommend this, though. If this file is really unused by the actual project, then why keep it there?
    Damian Reeves
    @DamianReeves
    @inosik Thanks
    I’m working on a library which I want to build to target dotnetcore and Fable. Everything is cool except for the fact I need JSON encoding/decoding and Thoth.Json separates its Fable vs Framework code into distinct NuGet packages. How are folks managing these situations since the Fable docs say your Fable library should have a simple .fsproj file with no conditionals?