Mixins #87
Closed
AliMD
started this conversation in
Educational
Mixins
#87
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is a Mixin?
Let's take for example Logging. Imagine you have 3 Pages
Now we want to log whenever someone goes on Page Red.
To archive that we extend Page Red and make a Logged Page Red.
If we want to start logging for PageGreen we have an issue:
Page
as Blue should not be loggedLogged PageGreen
as we can not extend from 2 source (even if we could it would mean conflicting info in Red and Green)What we can do is put it in an "external" place and write it so it can be "mixed in".
With that approach we can extract logic into a separate code pieces we can use where needed.
More in depth explanation
Beta Was this translation helpful? Give feedback.
All reactions