-
Notifications
You must be signed in to change notification settings - Fork 22
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
[microcosm] Split Subject.hash into separate class #514
Conversation
1fc7829
to
b727c7c
Compare
9939945
to
e2ca281
Compare
e2ca281
to
286c399
Compare
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.
code looks great and I love that this has been extracted into its own thing, but I also think that SubjectHash
is maybe a bit too generic of a name. I wasn't sure if Hash
was referring to a scrambled value (like encryption) or if it was similar to a Hash in another language like Ruby. Since it's converting to an object, how about SubjectObj
or an ObjectMapper.from_subject
function? Just some more thoughts that may or may not help you out.
f0c6d41
to
fd21b2c
Compare
The Subject.hash method was getting pretty massive, and I didn't like having it as a static method on Subject. This commit moves this function into a separate class that extends from Subject.
fd21b2c
to
a8acb59
Compare
Codecov Report
@@ Coverage Diff @@
## master #514 +/- ##
==========================================
- Coverage 98.79% 98.78% -0.02%
==========================================
Files 29 30 +1
Lines 745 738 -7
Branches 149 147 -2
==========================================
- Hits 736 729 -7
Misses 9 9
Continue to review full report at Codecov.
|
@zporter Renamed this to SubjectMap. I'm going to keep jamming on a name, but I'm hopeful that I'll hit some clarity once I've better distinguished the responsibility of this component in Presenters vs Microcosm itself. Thanks for the review! |
But it was getting pretty massive, and I didn't like having it as a static method on Subject. This commit moves this function into a separate class that extends from Subject.
What is Subject.hash
Subject.hash is a method used in a few places to reduce an object of nested asynchronous values into a POJO. This is extremely useful for building view models and for generally reducing down any complex async type in Microcosm down into something usable to the outside world:
This request behavior is additionally illustrated in the file-uploads example.
Why call it SubjectHash?
I don't know. I think this is the closest thing we have to the concept of a ViewModel, but it covers a broad use case of behavior. SubjectTree also came to mind, or something that doesn't use the word Subject, which is pretty vague. I have an issue to track that in #511