question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage without mixins

See original GitHub issue

When using ES Classes and/or TypeScript, it is not the best approach to use mixins. I know is possible, using class XYZ extends Component.extend(Mixin) { ... but it would be nice to not have an alternative to using mixins.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
mike-northcommented, Jul 9, 2018

Looking at the mixins in question, it doesn’t seem all that difficult for those who want a more explicit “composition instead of inheritance” option.

Example:

https://github.com/bgentry/ember-apollo-client/blob/5296032ff0b10ac3bd9bebf6cca8f56946c90929/addon/mixins/route-query-manager.js#L5-L8

99% of the complexity in this addon lives on the service, which is excellent. It’s very much true that a Router/Component/Object has an object that provides apollo support rather than being an object that includes apollo support.

If you don’t want to use the RouteQueryManager mixin, just inject the service:apollo yourself, and add the appropriate one-liners to your route (or a route base class).

For a first-class TS/ES6 approach, looks like the work would be:

  • document the mixin-free approach – effectively doing what the respective mixins do
  • add a few acceptance tests (A route, component and object) to protect against regression. The main thing that could go wrong in the future is ordering setup/teardown of the apollo client w/ the rest of the setup/teardown logic. As it stands, I doubt it matters if you do the apollo work before or after this._super(...arguments); but that could change. Tests would alert us to that change.
1reaction
tchakcommented, Dec 3, 2018

I implemented queryManager macro on my fork if some of you are interested in trying it out and give feedback. cc @buschtoens

https://github.com/tchak/ember-apollo-client/tree/drop-mixins

Read more comments on GitHub >

github_iconTop Results From Across the Web

mixin and @include - Sass
Mixins allow you to define styles that can be re-used throughout your stylesheet. ... Keyword arguments use the same syntax as variable declarations...
Read more >
Use without mixins · Issue #1619 · mainmatter/ember-simple ...
Is there a plan for allowing consumption of ember-simple-auth in a codebase that bans or restricts use of mixins?
Read more >
You Shouldn't be Using Mixins in Vue.js Anymore
Mixins are a way of reusing a functionality between components by merging the properties of a mixin with the component. It allows us...
Read more >
How to use Mixins in LESS, a CSS Preprocessor - SitePoint
LESS is a CSS Preprocessor. In this article we look at Mixins and other programming language like functionality that it holds.
Read more >
Mixins Considered Harmful – React Blog
Let's make it clear that mixins are not technically deprecated. If you use React.createClass() , you may keep using them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found