refx

repository·main·Indexed 41 days ago

https://github.com/ferdinand-beyer/refx

A port of the re-frame library for ClojureScript that utilizes React hooks instead of Reagent, designed for use with Helix or UIx. It introduces signal-based subscription handling via sub and use-sub, and provides HTTP request handling through refx.http and refx.http.easy.

Tokens
498
Snippets
1
Records
3
Agent score
50%

What's inside refx

  1. Choose between refx.http and refx.http.easy

    main

    The refx.http library provides two distinct flavors for handling HTTP requests via ClojureScript effects. You must choose one and avoid using both in the same project because they both register the :http effect key.

    • refx.http: Uses the standard ajax-request approach. It requires you to provide full request and response format descriptions (as defined by cljs-ajax). Use the :http or :http-xhrio keys.
    • refx.http.easy: Uses a more convenient "easy API". It supports shorthand keywords like :json or :transit for formats. Use the :http or :http-easy keys.
  2. How refx differs from re-frame

    main

    While refx is a port of re-frame using React hooks instead of Reagent, it introduces several key architectural changes:

    1. Subscription Handling: The subscribe function is replaced by two distinct tools:
      • sub: Returns a subscription signal. This is used as input in reg-sub functions.
      • use-sub: A React hook that returns a subscription's value.
      • Note: Neither of these are atoms and they do not require dereferencing.
    2. Dynamic Subscriptions: Query vectors can now contain signals returned by sub, enabling dynamic subscriptions.
    3. Flexible Inputs: Subscriptions are no longer limited to app-db. They can accept any input that satisfies the ISignal protocol, including atoms.
    4. Simplified Queries: sub and use-sub do not support the dyn-v argument used in re-frame, as refx provides superior alternatives via signals.
  3. Install refx

    main

    You can install refx using Clojure's dependency management tools. Releases are available on Clojars.

    deps.edn

    com.fbeyer/refx {:mvn/version "0.0.49"}

    Leiningen/Boot

    [com.fbeyer/refx "0.0.49"]

    Git Coordinate

    To use the latest development version via Git:

    {:deps {refx.core {:git/url "https://github.com/ferdinand-beyer/refx.git"
                       :git/sha "COMMIT_SHA"
                       :deps/root "core"}}}
    com.fbeyer/refx {:mvn/version "0.0.49"}