Questions tagged [mixins]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

What would I use to replace the css 'property' method so that I can imitate its use in a sass file?

Trying to recreate some css styles in a sass file and I ran across an issue which is making me think that the sass preprocessor is actually less capable then a basic css. ** Edited ** Within the sass ...
TVW96's user avatar
  • 3
0 votes
1 answer
29 views

Vue2 - What does a public/private method implementation look like in mixins?

I see that the following are documented, but I have trouble visualizing how this can be implemented. // Even better! var myGreatMixin = { // ... methods: { publicMethod() { // ... ...
0x5929's user avatar
  • 400
1 vote
1 answer
41 views

How to create a Mixin Enum

I'm trying to create an enum with a pathlib.Path mixin, MCVE: import enum, pathlib class Test(pathlib.Path, enum.Enum): path1 = pathlib.Path('/path1') path2 = pathlib.Path('/path2') which ...
alex's user avatar
  • 11k
0 votes
0 answers
19 views

Instantiate a hive object from json while preserving the key

When my class is extending HiveObject I have access to key using the getter defined in HiveObjectMixin but after sending the class instance through the network as JSON I need to convert it back to a ...
MOHAMMAD RASIM's user avatar
0 votes
1 answer
23 views

Global import and use of mixins file in Angular

is there a way to create global mixins.scss file in src/assets/style/mixins.scss and be able to use it in every component style sheet without importing it all the time? For the moment I managed to set ...
LaCodeM's user avatar
  • 686
0 votes
0 answers
17 views

Python: Add mixin per decorator with static type checker support

TL;DR: How to add a Mixin to a class with a decorator in a way that is understandable for static type checkers in VSCode? Its possible to dynamically add a Mixin to an existing class with a decorator: ...
ValeKnappich's user avatar
0 votes
1 answer
66 views

Mixin design to extend template parameter struct for various applications

I have a templated class that accepts structs as parameters (there is a reason for this that I won't get into here, but the design requires it). I am trying to generate a mixin design pattern (static ...
user3814483's user avatar
0 votes
1 answer
46 views

Error: Declarations may only be used within style rules

I declared my @mixin, and it didn't give me any problems, out of nowhere it started giving this error: @mixin flexbox ($justify-content: center, $align-items: center, $flex-direction: column, $flex-...
Sara's user avatar
  • 1
1 vote
1 answer
74 views

Live Sass compiler throws an error when processing the mixin

My problem: the live Sass compiler throws an error when processing the mixin: Compilation Error Error: 2 arguments required, but only 1 was passed. ╷ 8 │ $fontSize: rem(14); ^^^^^^^ Here is the ...
Ellegion's user avatar
0 votes
0 answers
27 views

Create a mixin called LoggerMixin that adds logging functionality to a class

I want Mixin to record the method name and its arguments when I call the info method from the car class, I asked the Chatgpt but it gave me a confusing solution with the getattrebute method. pleas ...
comiser's user avatar
  • 31
0 votes
0 answers
12 views

Where are blocks like hoppers, sculk sensors/ shreekers rendered(and how to cancel them all)

I am using Fabric 1.20.1 and trying to find out where blocks like these are rendered and how to modify it or cancel it. right now I am cancelling all blocks and blockentities from being rendered, and ...
G Schulz's user avatar
1 vote
1 answer
67 views

Access instance of outer class from mixin to inner class

I'm targeting a non-static nested class, e.g. package whatever; class Outer { public int x; class Inner { public void foo(); } } And I would like to write a SpongePowered Mixin ...
The Zach Man's user avatar
0 votes
0 answers
31 views

Vite/Vue3 OptionAPI mixin typings for props and head function with defineComponent

I have a problem to type our custom plugins for a ts mixins in vue3. We migrated our delivery from nuxt2/vue2 to vite/vue3. Having all our components written for OptionAPI, we have some mixins. Typing ...
Sebastian Wächter's user avatar
0 votes
0 answers
16 views

Considerations when replacing a Mixin with abstract Model subclass?

I have multiple Models that all need some shared functionality. My existing code uses a Mixin class: class MyMixing: some_class_variable = None @classmethod def get_headers(cls): ...
Granny Aching's user avatar
2 votes
2 answers
97 views

How do I utilize Javascript closure and private variables while also using Object.assign + Object.create in a factory function?

I'm trying to figure out how to incorporate factory function closures and use Object.assign/Object.create inheritance at the same time. Probably simple, but I can't figure out how to do it. First I ...
stuffz's user avatar
  • 23
-1 votes
1 answer
53 views

Mixins in django.?

Django’s built-in class-based views provide a lot of functionality, but some of it you may want to use separately. For instance, you may want to write a view that renders a template to make the HTTP ...
aaaa's user avatar
  • 73
0 votes
0 answers
65 views

Put object in array with Jackson mixin

I have some json and need to map it to other third party objects. JSON: { "date": "2023-01-01", "employee": { "idNumber": "29255", "gender&...
Valeriy K.'s user avatar
  • 2,658
0 votes
1 answer
28 views

Typescript mixin loose generic type

Consider the following, pretty basic example of typescript mixins: import { Observable, of } from 'rxjs'; class Service<TDataType> { public foo(f: TDataType): Observable<TDataType> { ...
Hafnernuss's user avatar
  • 2,659
0 votes
3 answers
83 views

How to create mixin classes that share the same member

How can I create mixin classes that share same members? I know this is probably a bad design choice but it is my last resort. here is an example of what I mean. though they are not sharing the same ...
ניר's user avatar
  • 1,214
1 vote
1 answer
50 views

Alternative to Jackson mixins for a variable number of subtypes?

I am writing a library, intended to be used by other apps, containing a bunch of classes that implement the same interface, like in this example: public interface Figure { // ... } public class ...
nomusicnolife's user avatar
0 votes
1 answer
21 views

Passing variables to mixin in LESS

I'm fairly new to LESS and mixins but i'm trying to generate a mixin to dynamicly generate some classes with certain variables. The mixin below is not working properly. Could anyone point me in the ...
Jochem's user avatar
  • 93
1 vote
1 answer
63 views

Initialize base class member in derived constructor if base is inherited via template

Given I know that a certain member a exists in my base class, how can I refer to it using my template-derived class? Even if I fully qualify a, it doesn't work: Demo #include <iostream> #include ...
glades's user avatar
  • 3,846
1 vote
1 answer
34 views

Typescript mixin function with generic type from main class

I have the following code // Types found on https://stackoverflow.com/a/55468194 type Constructor<T = {}> = new (...args: any[]) => T; /* turns A | B | C into A & B & C */ type ...
Guile's user avatar
  • 1,473
0 votes
1 answer
88 views

How to create a patch.object mock that I can start() and stop()?

So I have a large suite of unit tests in python, and I want to apply a set of 4 patches across all the tests (to disable expensive stuff). I have about 300 tests over 20 test classes, and I want to ...
thclark's user avatar
  • 4,794
0 votes
0 answers
28 views

Google docstrings in Python class

What's the correct way make google-style docstrings with private attributes in a class? I have this code for example: class IDMixin: """A mixin class generates unique IDs and ...
David 04's user avatar
0 votes
0 answers
30 views

Mixin giving "could be instantiated with a different subtype of constraint" error

In the following code Bar gives the error Class 'Bar' incorrectly extends base class 'TBase'. 'Bar' is assignable to the constraint of type 'TBase', but 'TBase' could be instantiated with a different ...
user2690730's user avatar
2 votes
1 answer
565 views

Unable to resolve Mixin error "$color: var(--bs-body-bg) is not a color", that has never occurred before

I ran the "npm run production" command as usual. But now I keep getting this error and I can't solve it. I didn't make any changes to assets (css, scss) only in controlers some code ...
Sahasrar's user avatar
-1 votes
1 answer
51 views

what's the difference between including a mixin with () and without () in sass?

I am creating a CSS library and I was using a mixin in my sass code, I was wondering what's the difference between @include btn and @include btn() in the example below? because they have the same ...
leo_256's user avatar
0 votes
1 answer
157 views

"Unused CSS selector" when using a SASS themify mixin with Svelte and Vite:

I'm trying to create a small web application using Svelte. One of the requirements is to be able to change the application "theme" on demand, for example - dark theme, light theme, high ...
Niv Zohar's user avatar
0 votes
0 answers
56 views

With MUI and Styled Components, can I extend an object with a serialized style from the library's css method?

I'm using MUI 6 with Styled Components, importing both styled and css from @mui/material/styles. If I write a SerializedStyled with the css method to use it as a mixin I get a SerializedStyle: export ...
maja's user avatar
  • 709
0 votes
1 answer
74 views

Ruby Mixin / Rails Concern share variable between all including classes

I'm trying to create a concern that holds fields mapping from including classes. Then I need to perform actions based on the data of all mappings. This is a simplification of what I currently have: ...
Gus's user avatar
  • 942
24 votes
1 answer
12k views

The class 'PreferredSizeWidget' can't be used as a mixin because it's neither a mixin class nor a mixin

After upgrading to Flutter 3.10 (and Dart 3), I am getting this error: The class 'PreferredSizeWidget' can't be used as a mixin because it's neither a mixin class nor a mixin. The current version of ...
Hossein Yousefpour's user avatar
0 votes
0 answers
528 views

Error with Using Mixins in Minecraft Fabric Modding

I tried to redirecte the Method tickMovement() in the SnowGolemEntity class to remove the passage where snow golems get damage from beeing in Hot biomes. I tried to start Minecraft but it failed. I ...
Nesselbrand's user avatar
1 vote
5 answers
173 views

How would one implement generic functionality which gets applied across various distinct classes without inheritance?

I need to define a function that can be used by multiple classes, but as far as I understand, inheriting from a superclass doesn't work for me. Essentially, what I would like to achieve is the ability ...
user21877241's user avatar
0 votes
0 answers
33 views

Mixin not able to deserialize the json

I am using mixin to deserialize json into POJO. My POJO: @Value.Immutable @JsonDeserialize(as = ImmutableStatusResponse.class) public interface StatusResponse { Status status(); } Status is an ...
LateInCoding's user avatar
0 votes
0 answers
81 views

Angular sass application doesn't recognize mixins at start

I have an angular web application with sass implemented. It works fine but only when the last change is saved in "styles.scss" (being that file the one with the imports of the other scss ...
Isabel's user avatar
  • 56
0 votes
2 answers
162 views

Typescript function return class cannot define private member

I wonder why I cannot define private members for my returned class that is generated with the below function. Does anyone know why it could not be private and protected? I saw this code somewhere but ...
sam's user avatar
  • 23
3 votes
1 answer
130 views

How to check if a class has a mixin applied in TypeScript? (inferring its type)

I am trying to determine if a TypeScript class has a specific mixin applied to it in a way that narrows its type (for autocompletion/intellisense), but I am encountering some difficulties. I have ...
GermanJablo's user avatar
0 votes
2 answers
91 views

Dynamically nest CSS Classes in SASS

I am trying to create dynamically nested classes in SASS. I am using React 18 and SASS 1.62 (Craco). I have a scss file that needs to look like this .gridRow.scss .root { &.row-cols-auto>* { ...
Jonatan Kruszewski's user avatar
0 votes
2 answers
94 views

Writing Typescript definitions for ES6 mixins

I am writing a Javascript UI library. Consider the following Javascript: class Image { constructor() { this.isImage = true; } } class Text { constructor() { this.isText = true; } } ...
TarczaBoga's user avatar
0 votes
1 answer
83 views

multiple class extensions with built-in classes

I've been looking at mixins in typescript and wonder how I could implement my problem. I have four classes: AudioNode (native) CustomAudioNode ( custom ) GainNode ( native ) CustomGainNode ( custom ) ...
JSmith's user avatar
  • 4,574
2 votes
1 answer
225 views

Automatically generating and chaining mixins for a typescript class

Here is what I have interface BaseEvent { type: string; payload: any; } interface EventEmitter { emit(event: BaseEvent): void; } class BaseClass { constructor(protected eventEmitter: ...
Yggdrasil's user avatar
  • 1,377
0 votes
0 answers
36 views

How to make composite mixin in Flutter?

For example, I have these mixins: mixin ImageField on ObjectBase { ImageSetModel get image => ImageSetModel().wrap(this["image"]); } mixin SizeField on ObjectBase { SizeModel get size ...
Chen Li Yong's user avatar
  • 5,509
0 votes
1 answer
60 views

React and bootstrap without importing and embedding into application

We all know how to import Bootstrap into an application (in this case React) but what happens when my React application will be embedded into a website that already has Bootstrap added as an external ...
Helmut Granda's user avatar
4 votes
1 answer
1k views

What is the point of `interface class` in Dart 3?

I have been playing around with Dart 3 a bit and am a fan of the new class modifiers. But one I can't seem to get my head around: why does interface class exist? I understand interface mixin because ...
Gregory Conrad's user avatar
0 votes
1 answer
89 views

You may have an infinite update loop in a component render function, caused by side effect in method

I've solved my issue, but I don't understand it (or maybe I do). I created an error handler plugin, basic example: main.js const bugStore = { state: [], addToState(bug) { this.state.push(bug); ...
user1447679's user avatar
  • 3,106
0 votes
1 answer
63 views

How to write some arbitrary initialization code in a Dart mixin?

Say I have a package that exposes a mixin that provides some extensibility through an API: mixin ListenerModifier<T> { T get value; void addListener(Callback callback); void removeListener(...
Gregory Conrad's user avatar
0 votes
1 answer
40 views

Following code still works after error render

I have a concern module as below concerns/onboarding.rb module Onboarding def status(onboard, params) if onboard.finished? && params[:process].present? render json: { error: 'You ...
user12763413's user avatar
  • 1,187
0 votes
0 answers
115 views

How to use Jackson Mixin to map JsonNode into an object?

Given is a JsonNode with several levels of depth. From this node a few properties (not all) are to be used to build an object from a 3rd-party class. The class has a no-arg constructor as well as ...
Slevin's user avatar
  • 351
0 votes
0 answers
70 views

How to type constructor/factoryless mixins?

We have a legacy JavaScript library that makes extensive use of mixins, but without the usual factory-function-plus-class-expression pattern; instead, it uses Object.assign in the constructor to mix ...
cpcallen's user avatar
  • 1,856

1
2 3 4 5
43