You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(function() {
'use strict';
Vue.component('basic-component', function() {
mixins: [{mixin: window.mixins.notification, as: 'notification'}],
created: function() {
// Will produce a mixins namespace suffixed with the name given for the mixin
this.mixins.notification.show();
}
})
})
The text was updated successfully, but these errors were encountered:
It would be even better to just do mixins: { notification: window.mixins.notifications } but I don't see why do you need this.
But this doesn't scale since you don't really know where the show() method comes from.
Yes, you know. It comes from the mixin you explicitly included in that component. The idea of a mixin is to reuse some behaviour across components in an explicit and transparent way, and how would it apply to other things like hooks?
If you want that namespace for functions that are not related to the component you want to use the mixin on, you can add the namespace yourself very easily the way you proposed
What problem does this feature solve?
I want to be able to create a namespaced mixin.
Let's take this notification mixin for example:
I can import it in my component and use it:
But this doesn't scale since you don't really know where the
show()
method comes from.This can be already "solved" using a prefix in the method such as:
but it seems a bad "implementation".
What does the proposed API look like?
Let's take my first example:
This could be injected in the component such as:
The text was updated successfully, but these errors were encountered: