Skip to content
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

Upgrade re-frame #15963

Closed
ilmotta opened this issue May 19, 2023 · 2 comments · Fixed by #15997
Closed

Upgrade re-frame #15963

ilmotta opened this issue May 19, 2023 · 2 comments · Fixed by #15997
Assignees

Comments

@ilmotta
Copy link
Contributor

ilmotta commented May 19, 2023

Problem

The last commit of the re-frame library we use is from Mar 7, 2020, version 0.12, more than 3 years ago. It's working decently, so why upgrade?

re-frame is very stable, but it introduced improvements in 2020 that we're dearly missing. Whatever is in double-quotes below is verbatim text extracted from re-frame's changelog.

  • There are some fixes of course, and very few breaking changes!
  • "Supports :fx, which allows for effects to be ordered." Mike Thompson explains in more detail the goals and importance of introducing :fx Ordered Effects day8/re-frame#639 (comment)
    • "You can include the same kind of effect multiple times (eg :dispatch) which means there is no longer any need for special effects like :dispatch-n. Indeed, all *-n style effects are now redundant. This feature is a stepping stone towards making it easier to create an event handler which is a composition of other functions". See any similarities with our custom utils.re-frame/defn macro and utils.re-frame/merge function?
  • "re-frame now guarantees that a :db effect, if present, will be actioned before any other sibling effects."
  • Support global interceptors. Among other things, useful for logging, global error handlers and inspecting events with a REPL.
  • "Add a new interceptor called unwrap. It decreases the amount of destructuring necessary in an event handler where the event is structured as a 2-vector of [event-id payload-map]." Great to be added as a global interceptor.
  • Syntactic sugar for trivial reg-sub declarations (see Feature Request: Syntactic sugar for trivial reg-sub declarations. day8/re-frame#634)

And then?

Once re-frame is upgraded, I would like to tackle the re-implementation of rf/defn and rf/merge to take advantage of :fx, and do it in a way that's as compatible as possible with our existing guidelines.

Notably, I think it would be possible to come up with a solution that's fully lintable by clj-kondo. Right now we need to code without almost any linter help in event handlers, and this is a cost we should not be paying since every little piece of the puzzle is in our hands. Last time I checked, changing clj-kondo to lint rf/defn as defn correctly found more than 200 warnings. Not to count the cost of refactoring tools that don't work with our current solution.

Limitations?

Do we have any library blocking us from upgrading? cc @flexsurfer, @cammellos, @ulisesmac

@ilmotta ilmotta self-assigned this May 19, 2023
@ulisesmac
Copy link
Contributor

Thank you so much for this issue. I'll do some research to find any potential problem and will comment on this issue!

@ilmotta
Copy link
Contributor Author

ilmotta commented May 19, 2023

Thank you so much for this issue. I'll do some research to find any potential problem and will comment on this issue!

Excellent @ulisesmac, thanks for that! I just tried to upgrade directly to 1.3.0 and by the magic of backwards compatibility the app works. I haven't tested any other dependency, like re-frisk.

ilmotta added a commit that referenced this issue May 31, 2023
This commit upgrades re-frame to v1.3.0 (latest stable release), released ~9
months ago, in 2022-08-27. This is a solid upgrade, with no breaking changes as
far as I tested status-mobile. It's a great testament of re-frame's stability
and commitment to backwards compatibility, as are many Clojure libs.

Fixes #15963

The big, and truly relevant addition is the introduction of the :fx built-in
effect that was added ~3 years ago in Aug/2020 in v1.1.0.

Relevant changelog:

- Global interceptors are now supported (added in v1.0.0).
- reg-event-fx will just warn (not generate an error) if the effect map returned
  contains an unknown effect key.
- re-frame will now warn us when we are calling subscribe outside of a reactive
  context.
- "re-frame now guarantees that a :db effect, if present, will be actioned
  before any other sibling effects. re-frame continues to provide NO guarantees
  about the order in which other effects will be actioned."
  (https://day8.github.io/re-frame/releases/2020/#110-2020-08-24)
- There's syntactic sugar for trivial reg-sub declarations (added in v1.3.0).
  See the documentation for reg-sub for more details
  https://day8.github.io/re-frame/api-re-frame.core/#reg-sub
- "The built-in effect :dispatch-later can now take a single map value.
  Supplying a sequence of maps is now deprecated in favor of using multiple
  :dispatch-later effects within the new :fx effect."
  https://day8.github.io/re-frame/releases/2020/#111-2020-08-26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants