-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Unify @tracked
and @action
export paths
#547
Comments
With IDEs that support automated imports, e.g. VS Code, when the typings for Ember packages are installed, this becomes a non-issue. Inversely, adding additional re-exports makes it slightly more complicated / annoying since you now have multiple places to chose from, adding some cognitive load. If we change the import paths, I'd recommend to drop Tangentially related #273 (comment): Renaming / Re-exporting import { service } from '@ember/service'; |
I'm not sure we're at the point yet where we can just accept IDE tooling as a solution across the board, though maybe we are. This also doesn't work for documentation and example code, which become much more bloated by always having to include a large list of imports, so anyone writing a blog post or trying to demo Ember will have a bit of extra burden. I do think the argument that this could harm IDE tooling is a good one though. There are good reasons for
There is disagreement on the terminology of
Definitely open to other ideas as well! |
I don't think any of these arguments should have an impact from where the named functions should be imported from. Find a home for them to where they belong and feel comfortable. Rest of it, ie IDE tooling will be the nice sugar to make that more ergonomic to us. Personally for me |
Glimmer will require a |
Unfortunately, the answer here is basically “no”. VS Code uses some heuristics based on recency (and maybe some other things! Not sure!) to determine what to import, but if you have multiple imports for a name available, all the major editors and IDEs will usually show you all of them.
I understand this objection, but I disagree with it and I’d like to take this opportunity to put in writing why. It is true that in general we want APIs to describe their intent—i.e. to make a given class method safe to pass around through templates (and elsewhere). It is also true that explaining function binding can get pretty hairy, especially for developers new to JavaScript. The fact that you can rebind what However, even granting those things, I think that attempting to paper over this or hide it is misdirected, however well-intended. First, it adds a layer of Emberism that’s the opposite of the direction we’ve been moving during the lead-up to Octane in general. Second, it misses an important pedagogical opportunity. I think that first point is fairly obvious, so I won’t belabor it. The second, though, warrants a bit of tracing out. Pedagogically, we want to minimize bumps as someone is coming up to speed on the framework, especially for someone just getting started with JS or even with programming in general. However, some bumps are actually useful when teaching, and I think this is one of them! Here’s why: the immediate question for anyone who wants to understand what’s happening when they see that we recommend decorating the function this way—i.e. any experienced JS developer, or any developer who isn’t happy just trusting things to magically work—is: “Why does this need to be decorated with
Substitute in
Either way, you can say “You don’t have to worry about the details to get started,” in other words. But there are other tradeoffs after you get past that (very helpful) hand-wave.
Regardless of what it’s named, you end up saying something like “this makes class methods safe to use in templates, and you can worry about the details of why later.” But there is one very important difference: You don’t need to understand function binding to be productive in JS right away. But you do need to understand it eventually. It seems to me that it’s extremely valuable to use a name that matches the actual thing you need to understand, which matches the base JS APIs on which it’s built ( Appendix – Search Results
Notice that Ember-specific knowledge is required for |
I tripped over these imports immediately with two issues:
I'm not sure I buy that With that being said, I'd vote for |
Independent of the name (though @chriskrycho's reasoning lines up pretty well with my thoughts), one thing that does jump out at me about Given that |
I think that’s a bit inaccurate, for instance I get how that could be confusing, but I think it’ll be clearer once EmberObject is deprecated and we can write apps without it. The same reasoning works for |
That's why I said " I know the two are usable independent of one another, but they're both intended not to be a significant part of the Octane programming model and are eventually slated to be phased out, aren't they? Are there things other than |
Ah, missed that part, my bad.
I believe that |
I'm closing this due to inactivity. This doesn't mean that the idea presented here is invalid, but that, unfortunately, nobody has taken the effort to spearhead it and bring it to completion. Please feel free to advocate for it if you believe that this is still worth pursuing. Thanks! |
One of the more common pieces of feedback we've been receiving so far with the Octane preview is that it's fairly burdensome to write out all of the import paths when writing a simple component:
The decisions for these import paths were made carefully and with good reason, but ultimately it's proving fairly unergonomic, and it may make sense to begin re-exporting some of them from a shared location.
We could re-export
@tracked
and@action
from@glimmer/component
, but they are also much more general decorators - they can be applied to Controllers, Services, Helpers, etc. We would either have to re-export from each of these for consistency, or force users to learn two potential import paths.Alternatively, we could group these two decorators, since they are usually applied together anyways. Some possibilities include:
The first decision would be whether to group them in an
@ember
namespace, or a@glimmer
namespace. The original decision forimport { tracked } from '@glimmer/tracking'
was that it would allow us to support interop between stand-alone Glimmer and Ember, so choosing an@glimmer
namespace would help with this goal.However, it would also introduce
@action
to Glimmer.js, and this may not be an ideal name for the function-binding decorator. The term "action" has a lot of historical baggage in Ember, and doing this would introduce that baggage to Glimmer. If we aren't satisfied with the name@action
, re-exporting from an@ember
namespace may make more sense. Either way, Glimmer.js will be needing to add a function-binding decorator in the near future, either@action
or some other name.The text was updated successfully, but these errors were encountered: