-
Notifications
You must be signed in to change notification settings - Fork 11
Decide how to use namespaces in the store #138
Comments
state.myOrg.myBlock.someStateValue
We also need to decide if the standard inside the store will be camel case or snake case: store( [
"state" => [
"myPlugin" => [
// ...
],
"my_plugin" => [
// ...
]
]
] ); store({
state: {
myPlugin: {
// ...
},
my_plugin: {
// ...
},
},
}); |
I would choose camelCase 🐫 . Most of the time, developers will interact with the store inside actions, derived state, etc., and, as those should be written in JS ―where the camel case convention is more widespread― I think it's the one that would make more sense. Also, although snake case is more common in PHP, in this situation, we're talking about array props ―which are strings―, not variable or function names. And there is a precedent in Gutenberg; for example, properties defined in This is just my personal opinion, though. I want to read others as well. 😄 |
I'd like to resume this conversation. It seems there are two main questions here:
|
Sure. No one has objected, so let's go with camel case (I agree with David's arguments) and a single namespace for the proposal 🙂 |
Closing the issue with the decision made. We can always reconsider it and reopen the issue if needed. |
I have been talking to @SantosGuillamot and we thought that just using the namespace after
state
,actions
,effects
, etc, should be enough to avoid collisions.The namespace should be the same as the one used in the blocks, defined in the documentation as:
Within the namespace, developers can do whatever they want. If they define values in the root, they will be as global values to their namespace, and if they have several blocks with properties that may conflict, they can also use the names of each block to further subdivide the state.
The definition of a single store would look like this:
And a complete store would look like this:
Thoughts?
cc: @WordPress/frontend-dx
The text was updated successfully, but these errors were encountered: