8 comments

  • moostee 31 minutes ago
    Proposed variant optimised for human readaiblity...

    ```js import mador from "mador"; const [read, write] = mador({ count: 1 }); read(".counter", ctx => ctx.el.textContent = ctx.count); write(".increment", "click", ctx => ctx.count++); write(ctx => ctx.count = 0); ```

    ## Read

    Dependencies are detected automatically when the read function is run during initiation.

    ```js read(".counter", ctx => ctx.el.textContent = `Count: ${ctx.count}`); ```

    ## Write

    Immediate:

    ```js write(ctx => ctx.count++); ```

    Event-triggered:

    ```js write(".increment", "click", ctx => ctx.count++); ```

    Event writes expose `ctx.el` and `ctx.event`.

    • bosmarcel 11 minutes ago
      O yes, thanks, appreciate it! I'm tired now, but i will find the time tomorrow to make it more readable!
  • bedroom_jabroni 12 minutes ago
    There are many standalone plug-n-play implementations of the signal primitive in JS. To name a few: preact/signals, vue reactivity, etc, there's even a TC39 proposal for a lang feature. Is this meant to stand out by doing things differently or reinvent them?
    • bosmarcel 8 minutes ago
      Honestly, mostly for the fun of building it and seeing how small and simple I could make it. While big solutions like Preact or Vue are great, sometimes you just want a tiny zero-dependency script without the overhead. And it turned out to be quite nice as I may say so
  • PoignardAzur 29 minutes ago
    Are reactive updates based on deep equality or reference equality?
    • bosmarcel 14 minutes ago
      It is based on ref. equality, so assignment through '=' will trigger an "effect".
  • DylanMerigaud 1 hour ago
    Clean launch, good luck!
  • ahmedhossamdev 43 minutes ago
    Great work!
    • bosmarcel 41 minutes ago
      Thanks, I really appreciate it! Hope others will feel the same. The frontend community needs and deserves simple tools:)
      • antonvs 21 minutes ago
        This makes me think of a version of that comic where in the last pane, you get thrown out the window for suggesting such a sensible thing.
  • hamburglar 0 minutes ago
    [flagged]
  • bosmarcel 1 hour ago
    [flagged]
  • dpweb 23 minutes ago
    [dead]