Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
We Distribute
  1. Home
  2. General Discussion
  3. The more I work on #ONI, which is basically a web components frontend for an as basic as possible #ActivityPub client to server service, the more I realize I'm just not built for JavaScript programming.

The more I work on #ONI, which is basically a web components frontend for an as basic as possible #ActivityPub client to server service, the more I realize I'm just not built for JavaScript programming.

Scheduled Pinned Locked Moved General Discussion
javasscriptlitjswebcomponentsfrontendactivitypub
8 Posts 2 Posters 286 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mariusor@metalhead.clubM This user is from outside of this forum
    mariusor@metalhead.clubM This user is from outside of this forum
    mariusor@metalhead.club
    wrote on last edited by
    #1

    The more I work on #ONI, which is basically a web components frontend for an as basic as possible #ActivityPub client to server service, the more I realize I'm just not built for JavaScript programming.

    Despite having put in the hours every day for a number of months, the whole Promise paradigm just doesn't seem to click for me.

    Now I'm struggling to create a throbber component (easy) while fetches happen in the background (easy) and then have it replaced (not easy) by actual content (easy).

    😱 Gaaah!!!

    #frontend #web_components #litjs #JavasScript

    opinionatedgeek@mastodon.socialO 1 Reply Last reply
    0
    • mariusor@metalhead.clubM mariusor@metalhead.club

      The more I work on #ONI, which is basically a web components frontend for an as basic as possible #ActivityPub client to server service, the more I realize I'm just not built for JavaScript programming.

      Despite having put in the hours every day for a number of months, the whole Promise paradigm just doesn't seem to click for me.

      Now I'm struggling to create a throbber component (easy) while fetches happen in the background (easy) and then have it replaced (not easy) by actual content (easy).

      😱 Gaaah!!!

      #frontend #web_components #litjs #JavasScript

      opinionatedgeek@mastodon.socialO This user is from outside of this forum
      opinionatedgeek@mastodon.socialO This user is from outside of this forum
      opinionatedgeek@mastodon.social
      wrote on last edited by
      #2

      @mariusor FWIW, I'm working on a similar thing, and I've settled into a pattern like this - the component has a spinner, a viewer, and a no-data message, then have a dataBind() method like:
      ```
      dataBind(data, binder) {
      if (data) {
      this.#spinner.style.display = 'none';
      this.#viewer.style.display = null;
      this.#noData.style.display = 'none';
      } else {
      this.#spinner.style.display = 'none';
      this.#viewer.style.display = 'none';
      this.#noData.style.display = null;
      }
      }
      ```

      mariusor@metalhead.clubM 1 Reply Last reply
      0
      • opinionatedgeek@mastodon.socialO opinionatedgeek@mastodon.social

        @mariusor FWIW, I'm working on a similar thing, and I've settled into a pattern like this - the component has a spinner, a viewer, and a no-data message, then have a dataBind() method like:
        ```
        dataBind(data, binder) {
        if (data) {
        this.#spinner.style.display = 'none';
        this.#viewer.style.display = null;
        this.#noData.style.display = 'none';
        } else {
        this.#spinner.style.display = 'none';
        this.#viewer.style.display = 'none';
        this.#noData.style.display = null;
        }
        }
        ```

        mariusor@metalhead.clubM This user is from outside of this forum
        mariusor@metalhead.clubM This user is from outside of this forum
        mariusor@metalhead.club
        wrote on last edited by
        #3

        @OpinionatedGeek litjs has an idiomatic way of achieving this kind of logic.

        It has an `until(promise, fallback)` function which waits for the promise to resolve and display fallback until then.

        Even with this simple setup I still get issues. 😄

        It's definitely a "me" problem. I'm holding it wrong somehow, but I haven't seen any examples in the wild of "holding it right".

        opinionatedgeek@mastodon.socialO 1 Reply Last reply
        0
        • mariusor@metalhead.clubM mariusor@metalhead.club

          @OpinionatedGeek litjs has an idiomatic way of achieving this kind of logic.

          It has an `until(promise, fallback)` function which waits for the promise to resolve and display fallback until then.

          Even with this simple setup I still get issues. 😄

          It's definitely a "me" problem. I'm holding it wrong somehow, but I haven't seen any examples in the wild of "holding it right".

          opinionatedgeek@mastodon.socialO This user is from outside of this forum
          opinionatedgeek@mastodon.socialO This user is from outside of this forum
          opinionatedgeek@mastodon.social
          wrote on last edited by
          #4

          @mariusor That sounds so frustrating! (I feel your pain. I've given up in the past on libraries/add-ons that did complicated jobs but had no docs to tell me how to use them. I love examples!)

          I do like the sound of that `until()` approach. I went with an ever-more-complex databinding approach that causes me some problems with large ActivityPub objects...

          mariusor@metalhead.clubM 2 Replies Last reply
          0
          • opinionatedgeek@mastodon.socialO opinionatedgeek@mastodon.social

            @mariusor That sounds so frustrating! (I feel your pain. I've given up in the past on libraries/add-ons that did complicated jobs but had no docs to tell me how to use them. I love examples!)

            I do like the sound of that `until()` approach. I went with an ever-more-complex databinding approach that causes me some problems with large ActivityPub objects...

            mariusor@metalhead.clubM This user is from outside of this forum
            mariusor@metalhead.clubM This user is from outside of this forum
            mariusor@metalhead.club
            wrote on last edited by
            #5

            Hey @OpinionatedGeek I see you're working on ActivityPub stuff, is the code public to look at?

            1 Reply Last reply
            0
            • opinionatedgeek@mastodon.socialO opinionatedgeek@mastodon.social

              @mariusor That sounds so frustrating! (I feel your pain. I've given up in the past on libraries/add-ons that did complicated jobs but had no docs to tell me how to use them. I love examples!)

              I do like the sound of that `until()` approach. I went with an ever-more-complex databinding approach that causes me some problems with large ActivityPub objects...

              mariusor@metalhead.clubM This user is from outside of this forum
              mariusor@metalhead.clubM This user is from outside of this forum
              mariusor@metalhead.club
              wrote on last edited by
              #6

              @OpinionatedGeek I finally got a workable version, though I am not very satisfied with it.

              You can see it in action on my metal releases bot/ActivityPub playground: https://releases.bruta.link/outbox

              The tab at the top corresponds to the outbox collection of the actor it gets loaded in the background to show an eventual icon/name change.

              opinionatedgeek@mastodon.socialO 1 Reply Last reply
              0
              • mariusor@metalhead.clubM mariusor@metalhead.club

                @OpinionatedGeek I finally got a workable version, though I am not very satisfied with it.

                You can see it in action on my metal releases bot/ActivityPub playground: https://releases.bruta.link/outbox

                The tab at the top corresponds to the outbox collection of the actor it gets loaded in the background to show an eventual icon/name change.

                opinionatedgeek@mastodon.socialO This user is from outside of this forum
                opinionatedgeek@mastodon.socialO This user is from outside of this forum
                opinionatedgeek@mastodon.social
                wrote on last edited by
                #7

                @mariusor Nice! I like the way the data flows through the `it` attribute.

                FWIW here's how your post looks in my C2S code. Depending on circumstances, each of the main bits (the profile picture, name, each addressee, the replied-to actor, and the content) may be demand-loaded.

                mariusor@metalhead.clubM 1 Reply Last reply
                0
                • opinionatedgeek@mastodon.socialO opinionatedgeek@mastodon.social

                  @mariusor Nice! I like the way the data flows through the `it` attribute.

                  FWIW here's how your post looks in my C2S code. Depending on circumstances, each of the main bits (the profile picture, name, each addressee, the replied-to actor, and the content) may be demand-loaded.

                  mariusor@metalhead.clubM This user is from outside of this forum
                  mariusor@metalhead.clubM This user is from outside of this forum
                  mariusor@metalhead.club
                  wrote on last edited by
                  #8

                  @OpinionatedGeek nice, I like that you display explicitly the recipients.

                  So far everyone seems to want to paper over that whole mechanism with the "public" "followers" "mentions" model that Mastodon engendered.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  Powered by NodeBB Contributors
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups