-
Notifications
You must be signed in to change notification settings - Fork 0
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
Modularize core functionality, consolidate global state #2
base: master
Are you sure you want to change the base?
Conversation
[re-frame.registry :as reg] | ||
[re-frame.std-interceptors :as stdi])) | ||
|
||
(defprotocol IFrame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is a good idea or not, but I wonder what would happen if we had IDispatch
, ISubscribe
, e.t.c.. Would that open things up for testing more, or is it unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I briefly thought about it but it didn't "jump at me" as the right way to do it. Also wanted to keep the change focused and free from smaller design decisions like this.
This is looking positive. I think the thing that Mike and I have always wondered is how this looks/works in a real application. Would you be able to port the todomvc to pass a frame around to see how it looks? |
@danielcompton The todomvc continues to work with these changes as the core API is maintained through the Mike mentioned that he is eager to see how this passing around would work and that he'd like to hold off changes like this one before that part is worked out... The change presented here however isn't aiming to address that. Reagent doesn't provide a way to work with React's Context yet and I don't have any good ideas right now (besides childContext) for that part. That said this change should make it a lot easier for everyone to experiment with their ideas around this problem which to me seems like a logical first step. |
Ah of course, I see now. |
This honestly looks like a good ol' refactoring, with no API changes, which is good. I have not go deep into the code but I'd like to try it in one of my apps and report back. |
679a63c
to
f59246f
Compare
ed4756b
to
a38ba42
Compare
@danielcompton @arichiardi @mike-thompson-day8 I updated this PR against latest master and implemented a few more changes (notably around the subscription cache and default interceptors). At this point I would appreciate feedback & suggestions to carry this further. Also just running one or two more complex app on this branch would be of great help to find bugs the tests didn't catch. If that happens I would be happy to extend the test suite as well. |
Add re-frame-datatable to External-Resources.md
Fix links to DataScript database
92757f8
to
65209c3
Compare
65209c3
to
823930a
Compare
:event-queue event-queue | ||
:app-db re-frame.db/app-db | ||
:subs-cache subs-cache | ||
:default-interceptors [(cofx/inject-cofx registry :db) (fx/do-fx registry)]}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Goals (tl;dr)
Goals (prose)
This is part of an attempt to consolidate state into
re-frame.core
so that other re-frame namespaces can be used in a more library-like manner. The goal is not to make this easy to use for regular re-frame users or even the default but rather step by step reduce how state is spread out across the codebase. Later on this should simplify the implementation of "multiple re-frame instances" and similar scenarios (e.g. devcards or using re-frame's eventloop/fx/cofx stuff with non-reagent projects).There are a few critical pieces of state as far as I can see:
re-frame.registrar/registry
forcofx
event
fx
andsub
re-frame.router/event-queue
FSM for processing eventsre-frame.subs/query->reaction
subscription cachere-frame.db/app-db
Changes
re-frame.registry
,re-frame.router
, andre-frame.subs
namespaces intore-frame.core
and parameterizes the public API accordingly. Furthermore it turns the registry and subscription cache into a protocol and record similar to what's done inre-frame.router
.re-frame.db/app-db
is still used directly as before.re-frame.registrar
has been renamed tore-frame.registry
(why?)TBD
frame
singleton is still TBDreg-event-*
should be provided as arguments when creating frames so that it is possible to create a frame without any interceptors.