-
Notifications
You must be signed in to change notification settings - Fork 33
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
docs(data-point/README.md): State in README that constants should not contain other reducers #213
docs(data-point/README.md): State in README that constants should not contain other reducers #213
Conversation
…ucers should not contain other ViacomInc#201
Just fyi you should preface the " https://help.github.com/articles/closing-issues-using-keywords/ |
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.
LGTM!
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.
can we change the wording a bit, i believe its not that yoy should not pass a reducer, but that which ever value you pass will be evaluated only as a constant/static value ? @raingerber @paulmolluzzo ?
@acatl I see your point, sure. 🤔 Maybe it's good to keep this small line and add what you wrote too? Something like:
I'm not sure of the wording of the last sentence, tbh. It also feels like we're repeating the same thing a few times. (e.g. "Constants are constant and return a static/constant value...") 😅
|
I can't think of a better way to explain this in words, but having an example to go with the current text might help. Here's a quick example that (hopefully) could be shortened: const DataPoint = require('data-point')
const { constant } = DataPoint.helpers
const dataPoint = DataPoint.create()
const input = {
b: 1
}
// ReducerObject that contains a ReducerPath ('$a')
let reducer = {
a: '$b'
}
dataPoint.resolve(reducer, input) // => { a: 1 }
// both the object and the path will be treated as
// constants instead of being used to create reducers
reducer = constant({
a: '$b'
})
dataPoint.resolve(reducer, input) // => { a: '$b' } |
closing this PR since it hasn't been active, please re-open it once you have it ready |
Providing an example to demonstrate what happens when you pass a reducer inside of a constant ViacomInc#213
79a32c4
Instead of changing the description of constants to say you shouldn't put reducers inside of constants, I added the example @raingerber made in order to show what happens when you do. |
@@ -1211,6 +1211,34 @@ constant(value:*):* | |||
``` | |||
</details> |
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.
we should still keep the "Constants should not contain other reducers." sentence that you originally added
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.
Good idea
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 rather have it taken off or changed since the actual content of a constant could be later on used to build a reducer. The only fact is that constant will not evaluate their content, they can contain any type of value. So this comment is misleading.
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.
if we pass a reducer function as a constant, on a second iteration another reducer could use this value to execute itself
'model:foo': {
value: [
{ a: c((val) => val * 2) },
(val) => val.a(2)
]
}
This only applies to Function Reducers, what I'm trying to articulate is just that constants can have anything, even a reducer if they want, just nothing will be evaluated, everything is taken as-is
packages/data-point/README.md
Outdated
@@ -1211,6 +1211,34 @@ constant(value:*):* | |||
``` | |||
</details> | |||
|
|||
|
|||
<details> | |||
<summary>constants that contain other reducers will not be evaluated</summary> |
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.
this summary is a little misleading, since these constants are still "evaluated". not sure how to reword it though; maybe something like this?
reducers are not evaluated when they're defined inside of constants
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.
More specifically, no functions inside of a constant
are evaluated, right?
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.
That's true, but this particular example doesn't have a function inside of a constant. If we do add that to the example (which wouldn't hurt), we still want to get across the fact that any reducer type inside a constant is not evaluated
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.
Cool, thanks for confirming.
Re-added the line about constants not containing other reducers, changed the summary of the new example ViacomInc#213
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.
Please remove the section 'Constants should not contain other reducers.' everything else looks good to me.
@@ -1211,6 +1211,34 @@ constant(value:*):* | |||
``` | |||
</details> |
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 rather have it taken off or changed since the actual content of a constant could be later on used to build a reducer. The only fact is that constant will not evaluate their content, they can contain any type of value. So this comment is misleading.
It doesn't really make sense to do that, and I don't think it's actually possible. |
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.
Still looks good to me. As long as everyone’s OK with the phrasing.
packages/data-point/README.md
Outdated
|
||
|
||
|
||
in options](#options-with-constants) example. |
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.
Extra lines?
closes #201