8000 GitHub - itarck/re-fancoil: A proof-of-concept exercise, deconstruct Re-frame first, then refactor it with integrant.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 6, 2022. It is now read-only.
/ re-fancoil Public archive

A proof-of-concept exercise, deconstruct Re-frame first, then refactor it with integrant.

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
license.txt
Notifications You must be signed in to change notification settings

itarck/re-fancoil

Repository files navigation

re-fancoil

Only a proof-of-concept exercise, deconstruct re-frame first, then refactor it with integrant.

Don't use this in project, hava a look at fancoil.

The ideal system structure

  • Parts: parts carry new features. Parts are immutable data and functions.
  • Machine: machines are built up from parts and have a state (atom) that changes over time in production.
  • System: system is responsible for coordinating multiple machines, use configuration file to start all machines in order of dependency.

Problems with re-frame

Hidden atom in the system: mainly registrar's kind->id->handler, subs' query->reaction, db's app-db Creating a system with hard-coded reg processes: mainly reg-sub, reg-event-*, reg-fx, reg-cofx, etc.

Principles of refactoring

  • Correct dependencies: parts (value, fn) -> machine (atom, async) -> system (integrant). The top layer depends on the bottom layer, each layer will depend on its own related libraries
  • More parts, simple system integration: because machines and systems are mutable
  • Transparent system structure, flexible machine configuration

Description of re-fancoil

Pulled out the hidden atom, put it inside the integrant init-key function, and inject it to other machines after system startup

Parts include input-fn and handler-fn for subscribe machine, and interceptor and handler for event machine, reagent-view-fn, registered to registrar at startup.

Added keyword interceptor to load interceptors already registered in registrar.

Changed input-fn for subscribe, query-vector -> dependent query-vectors, no longer dependency on previous subscribe function

Only part of code have been refactored, logger, trace, setting, are still global variables unchanged.

Framework code in re-fancoil folder, and example code in simple-re-fancoil and todomvc-re-fancoil folder

About

A proof-of-concept exercise, deconstruct Re-frame firs 5D74 t, then refactor it with integrant.

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
license.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0