-
Notifications
You must be signed in to change notification settings - Fork 11
Rename wp_store
to something else
#136
Comments
I like the There's some prior art for naming in this space:
|
I like |
I agree with Michal and Mario―maybe we are a bit biased with |
Let's use |
@gziolo mentioned to me that I'm reopening so we can discuss again. |
It only applies to PHP. On the JavaScript side, devs import Technically speaking, |
Pardon my ignorance, but is the convention that plugins must not use function names that start with Is there any other resource about function names other than what is in the PHP Coding Standards? |
Yes, I know how it sounds, and your response is spot on.
I think it's becoming "safer" when plugin developers follow Best Practice: Prefix Everything. The best approach would be to ask on WordPress Slack in the #core channel. |
So, what do you think about |
It made me think that someone had to make similar decisions when bringing WP Hooks and i18n helpers to JavaScript. @adamsilverstein, or @swissspidy do you have any recommendations? I see that for hooks, API looks the same but follows language-specific coding styles, in effect:
For i18n it seems like it was possible to achieve one to one match for equivalent methods. |
Not sure if these are good examples, because there we ported already very established PHP functions to JS, not vice-versa. Here it's a new thing for both sides. My 2 cents after a quick glance: "store" is a very generic term and without additional context a (new) developer would probably not understand what a For JS it doesn't seem a big issue as you import from the package, which gives you that additional context. Keeping But for PHP, could it perhaps be named more verbose, e.g. |
Thanks, Pascal 🙂 I think it makes sense to find something more verbose. But until we do, let's switch from
|
Closing the issue as the decision was taken: We'll use We can always reconsider it and reopen the issue if needed. |
I also think |
Reopening in light of the comment from Matias above. Suggestions to brainstorm this some more:
|
wpx
to something elsewp_store
to something else
What about
For me, speaking of |
Yes, that's true at the moment, and I like those suggestions! 🙂 That said, there are some (still very distant) ideas of serializing more than just the state. Whatever name we come up with, I'd like to plan for that eventuality. So, either we have to be fine with potentially creating a new function in the future (if we end up serializing more than just the state), or we find a more flexible name now. |
Total new voice here, but |
Do tell 😄 |
I really can't say too much! Not because I don't want to, it's just that the ideas are not yet well-formed. Also don't want to derail this thread 🙂. There are some ideas from over a year ago in WordPress/gutenberg#38224 exploring compiling a template format to both JS and PHP. More recently, some of us working in this repo have talked about building a similar template compiler where the If you want to talk about it some more, let's open a new issue, and let's cc @luisherranz, who might have some more thoughts on this front. |
I think |
I don't think we need to serialize anything else than The store, however, can contain other properties, like $counter = 0;
wp_store( array(
'state' => array(
'myPlugin' => array(
'counter' => $counter,
),
),
'selectors' => array(
'myPlugin' => array(
'double' => $counter * 2,
),
),
) ); store({
state: {
myPlugin: {
counter: 0, // Not really needed if you have declared it in the server
},
},
selectors: {
myPlugin: {
double: ({ state }) => state.myPlugin.counter * 2,
},
},
}); Whether there's a fixed number of properties ( I reckon wp_xxx_state( array(
'state' => array(
'myPlugin' => array(
'counter' => $counter,
),
),
'selectors' => array(
'myPlugin' => array(
'double' => $counter * 2,
),
),
) ); |
One more note here, the state is global, so the name would end up somewhere close to |
I would highly suggest to use the word No need to reinvent the wheel. Developers will already know what this means which will eliminate the cognitive load of learning new naming conventions. |
I'm going to close this issue as part of the migration to the Gutenberg repository. Please, feel free to open a new discussion in the Interactivity API category to discuss this matter further. |
We've wanted to find a better name for what we've been calling
wpx()
for a while, and @michalczaplinski just suggested usingstore()
:I'm not sure if the WordPress community would accept such a generic name, but I like it because it is explicit, and if we can, I'd prefer to avoid more than one word to avoid the camelcase vs snakecase confusion. I.e.,
addStore
vsadd_store
.Any thoughts? Other ideas?
The text was updated successfully, but these errors were encountered: