Questions tagged [mixins]

A mixin is a way to enhance an object with properties or methods from another object without inheriting from that object.

Mixins are related to inheritance in that an object receives properties or methods from another object but are typically not limited in number. They are often used as a way to "tack on" behavior to objects rather then to say that objects are related to each other.

For example, we may have an Album class. Since an album has multiple tracks, we may want to enumerate through it; however, it is also very similar to our Single class. In our design, we may then inherit from Single, but also choose to mix in Enumerable, a mixin that defines mechanisms for enumerating an object.

2137 questions
0
votes
1 answer

Case-specific mix-ins?

Is there a way in python to inherit different mixin classes depending on some other argument? Example: a = MyClass(case='A') # spawns a class instance which inherits MixinA b = MyClass(case='B') # spawns a class instance which inherits…
Bob
  • 428
  • 3
  • 11
0
votes
1 answer

get all functions marked by decorator of a class

I'm trying to store specific actions that are defined within a class. To reduce code duplication, I would like to make use of a mixin class that stores all the actions based on a decorator. The idea is that it should be straightforward for other…
user7431005
  • 3,899
  • 4
  • 22
  • 49
0
votes
0 answers

How to acess child object via param

I have an Vue app with this data: data: { personal: { email: '', first_name: '', last_name: '', password: '', password_confirmation: '', phone: '', work_email: '' }, company: { …
Igoohd
  • 136
  • 7
0
votes
1 answer

How to use classes with mixins as types in typescipt

I have the following code type GConstructor = new (...args: any[]) => T; class Sprite { name = ""; x = 0; y = 0; constructor(name: string) { this.name = name; } setPos(x:number, y:number) { this.x = x; this.y = y …
Zachiah
  • 1,750
  • 7
  • 28
0
votes
2 answers

How can I use spread syntax to copy object properties from multiple unknown objects in JavaScript?

I would like to use spread syntax to copy properties from several unknown objects into one object. Something like this: var array = [{a:0}, {b:1}, {c:2}]; // This array could hold any number of objects // This function should take the objects in…
Frank
  • 2,050
  • 6
  • 22
  • 40
0
votes
1 answer

Any way to avoid passing all parameters in styled components mixin?

I use styled components and have a mixin with many default parameters similar to this `export const myMixins = { font: ( fontFamily = 'Arial', weight = 600, size = '10px', style = 'normal') => ` font-family: ${…
Kiki
  • 117
  • 1
  • 3
0
votes
0 answers

Dart: Use mixin to outsource implementations for abstract methods

my Goal is to structure my code with this. The Idea is to outsource an inplementation to elsewhere, so that your main class is not so overloaded with way to much methods. Mixins seamed to be perfect for that! Example: abstract class Animal { …
puaaaal
  • 196
  • 8
0
votes
1 answer

Pseudo class after & before only display when with position absolute

I use mixin SASS to called background because I will use this code often. I will use the background mixin to create pseudo-class after and before. This the code of the background mixin: @mixin background($height: 10%){ content: ''; position:…
Yustina Yasin
  • 147
  • 2
  • 12
0
votes
1 answer

UserCheckout matching query does not exist

I'm trying to display all orders matching each logged in user, I dont understand why it gives me issues when trying to filter for users as it gives me that UserCheckout does not have any matching queries: orders/views.py class…
0
votes
1 answer

no mixin named flexdisplay

This is my _mixins.scss file: @mixin flexdisplay($flex_direction:column, $justify:center) { display: flex; justify-content: $justify; align-items: center; flex-direction: $flex_direction; } And this is my _header.scss file: .header…
Yustina Yasin
  • 147
  • 2
  • 12
0
votes
2 answers

Merge mixin in vue

I'm working in vue/quasar application. I've my mixin like this in my view.cshtml var mixin1 = { data: function () { return { data1:0,data2:'' } } , beforeCreate: async function () { ...} …
YannickIngenierie
  • 602
  • 1
  • 13
  • 37
0
votes
1 answer

SCSS @import mixin in React imported style

I'm trying to use SCSS in my React App made by Create React App. I have file called mixin.scss that I need to import in SCSS file, usually I used Ruby Compass and this just worked; @import '_mixin'; but using node-sass in React app from CRA it…
sjiamnocna
  • 167
  • 1
  • 11
0
votes
1 answer

ASPNetCore 3.1 + Bootstrap Mixins not compiling

How do I include a bootstrap mixin, in an ASPNetCore project? I have Web compiler installed. I added an scss folder and copied the alerts-variant mixing code from…
turkinator
  • 905
  • 9
  • 25
0
votes
1 answer

Implement mixins in TypeScript without using any type

I am wrangling with this mixin-creating TypeScript code: function applyMixins(derivedCtor: Function, constructors: Function[]) { //Copies methods constructors.forEach((baseCtor) => { …
Passiday
  • 7,573
  • 8
  • 42
  • 61
0
votes
0 answers

VueJS use EventBus in mixin

Here my code : A random component : watch: { 'notifications' : { handler(newVal) { let questionnaireTypes = ['TwoDaysConnected', 'OneWeekConnected', 'TwoWeekInactive'] if(newVal) { …
Tony S
  • 491
  • 6
  • 26
1 2 3
99
100