Skip to content
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

Mixins execute backwards #57

Open
jonathanazulay opened this issue Jun 29, 2016 · 3 comments
Open

Mixins execute backwards #57

jonathanazulay opened this issue Jun 29, 2016 · 3 comments

Comments

@jonathanazulay
Copy link

In my application I do something like this

mixins: [LoggedInMixin, UserIsBlaBla]

The second mixin in the array depends on something in Meteor.user() so we need to make sure the user is logged in first. But, unexpectedly, mixins will run in reverse order so I have to reverse the array:

mixins: [UserIsBlaBla, LoggedInMixin]

@jonathanazulay jonathanazulay changed the title Mixins execute in reverse order Mixins execute backwards Jun 29, 2016
@stubailo
Copy link
Contributor

You're right! We do a forEach over the mixins, and so if they wrap the run function it goes like:

// First:
loggedIn(run())

// Second:
userIsBlaBla(loggedIn(run))

But I think we pretty much can't change it now since that would probably break many things, so would you mind submitting a PR to the docs that reminds people of this?

@jonathanazulay
Copy link
Author

Oh I see. If you think about how it actually works - that mixins just wrap run() it makes sense. You could argue that just forEach-iterating is the right way aswell since mixins likewise could be dependent on properties added to the methodOptions in a earlier mixin. So never mind this then.

I'll submit a docs PR this week 👍

@abernix
Copy link

abernix commented Nov 14, 2017

@jonathanazulay I realize this is quite old but, did this doc update PR ever occur somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants