#mixin for a guard vs setMetaData

5 messages · Page 1 of 1 (latest)

summer hedge
#

hello, i need to pass a parameter to one of my guards and found that there are two solutions, either that you use a mixin or setMetaData.

the mixin method seems easier but I was curious if it's somehow less performant? since we are instantianting a new object every time with the mixin. or would it be negligible?

Any other pros and cons i need to take into consideration? (other than ease of use)

thorny owl
#

I find metadata aproaches more useful when you have guards that you want to bind at the class or global level, but have different functionality at the route route handler or class level.

Mixin guards, like AuthGuard(), are good when you want to pass parameters where you bind the guard

summer hedge
#

in that case mixin makes more sense for my use case. thank you

thorny owl
#

Yep precisely