No BS TS #17 - Mixins in Typescript

Поділитися
Вставка
  • Опубліковано 5 вер 2024

КОМЕНТАРІ • 44

  • @yourplayer5
    @yourplayer5 3 роки тому +14

    I have yet to come across a use case for Mixins in my daily work, but I love the concept👍
    It is really cool to see new stuff like this and I am a big fan of your No BS TS series so far.
    I am really looking forward to all the content that you will create

  • @ryanzwe
    @ryanzwe Рік тому +2

    This one completely blew my brain up, especially the use of it with generics

  • @mohdhaziq9859
    @mohdhaziq9859 3 роки тому +4

    Thank you Sir, i had difficulty dealing with Mixins with Class type currently. I'll be using your fantastic approach for my case. Thank you again.

  • @brijspy
    @brijspy Рік тому +1

    This video literally goes above my head at the end

  • @ThomasBurleson
    @ThomasBurleson 2 роки тому +2

    Love the use of generics to constrain the mixable source. This actually does not mutate the source but creates a new class that is a mixin of functionality. Wow, I did not know you could do this.

    • @ThomasBurleson
      @ThomasBurleson 2 роки тому +1

      Btw, your videos simply superb. Even as developer very familiar and comfortable with TypeScript, I learn something from EVER one of your videos. Some I have watched multiple times. Your pace and tersity is wonderful. Keep up the great work!

  • @valeriofunk5000
    @valeriofunk5000 2 роки тому +1

    typescript is beautiful suggar syntax everywhere. i spent like 30 min figuring out all those types and got it right. And then you explained everything very simple. i should have watched the last part befoure pausing it hehe

  • @1Malak16
    @1Malak16 2 роки тому +4

    This one was really advanced. Will try to return to it tomorrow. Wasn't able to fully grasp it.

    • @jherr
      @jherr  2 роки тому +1

      it is a mind bender for sure.

  • @collinsk8754
    @collinsk8754 Рік тому +1

    Great explanation. Mixins used quite a bit in the Angular framework.

  • @MrDima123123
    @MrDima123123 2 роки тому +1

    Very good explanation! Much better than on documentation.

  • @victorlongon
    @victorlongon 3 роки тому +2

    this is really interesting byt as others pointed I don't see directly use cases for it (I might be wrong). Nonetheless, the video was really nice and worth watching for the knowledge itself. Thanks, Jack!

  • @DavidSmith-ef4eh
    @DavidSmith-ef4eh 3 роки тому +4

    It's not complicated, but requires too much work to get it working. In dart you just use the "with" keyword in the class definition. Would be incredible if MS implemented this into TS, but I doubt it, since they follow ES too closely.

    • @jherr
      @jherr  3 роки тому +5

      You are correct. Typescript is never going to whole sale add new language features. An underlying tenet of TS is that you can remove all the type annotation and have code that runs as JS. Personally I'm ok with that. I like that TS is just "JS with types". There are lots of languages out there that compile to JS and have an entirely different syntax (e.g. Elm). And if that's what people want they can do that. But it's nice to have TS in this space of tracking to JS.

    • @emdadgar_official
      @emdadgar_official 2 роки тому

      ​@@jherr it seems v8 is very fast that "compilers developers" never wants to replace the JS interpreter iteself
      do you is it worth to have an enitrely independet engine for typescript ?
      beacause it's something higher than a just superset lang ... it's perfect i think .

  • @ZakiWasik
    @ZakiWasik 3 роки тому +7

    Wow. I know how to do composition in JS, but have really been scratching my head over the Typescript way for the past week or so. I click on your video and suddenly everything "clicks" for me and I wonder how come I did not find that video the first time I was researching this. Turns out it was uploaded today :D Instantly subscribed!
    What is your opinion on using applyMixins as described in the TS docs here? I can't really work out the benefits of using either approach over the other. They mention in the docs that applyMixins rely on your codebase over the compiler to keep the build- and runtime type-system in sync. But I'm not really sure what the implication of this is in practice?

    • @ZakiWasik
      @ZakiWasik 3 роки тому +1

      Forgot to paste in the link to the docs: www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern

  • @CesarWilliamBR
    @CesarWilliamBR 3 роки тому +2

    great video! thanks for sharing!

  • @soobhhann6746
    @soobhhann6746 3 роки тому +1

    you have the best tutorials thanks for your videos

  • @bidaarle
    @bidaarle Рік тому

    you can use a generic and replace "getObject():object" in line 52 with "getObject():K" to make it more open and not bound to an object type.

  • @yaserghananwi
    @yaserghananwi 2 роки тому +1

    Jack , really nice tutorial i need more and more example about this feature Mixins in real work or when can I used it .

  • @avneet12284
    @avneet12284 3 роки тому +1

    That's insanely good

  • @marcoscarlomagno3065
    @marcoscarlomagno3065 2 роки тому +1

    What kind of black magic is this? so cool!

  • @deemaagog
    @deemaagog 3 роки тому +1

    That was very helpful, thanks. BTW, how do you draw on screen ?

    • @jherr
      @jherr  3 роки тому

      I use Screen Brush and a tablet.

  • @dawid_dahl
    @dawid_dahl 2 роки тому +1

    You both look and sound like another person I like and listen to a lot, Sean Carroll. Sorry I just had to say it. 😄
    Thanks a bunch for all your great content! 🙏🏻

    • @jherr
      @jherr  2 роки тому

      The physicist?

    • @dawid_dahl
      @dawid_dahl 2 роки тому

      @@jherr Indeed! 🙂

  • @sam-zy2dn
    @sam-zy2dn Рік тому

    Thank you for your amazing videos Jack ! I am learning concepts from your videos indeed. I tested your initial class return from the function but I get an error that "Property 'completeLog' of exported class expression may not be private or protected." So basically it should be marked as public. But I wonder how in your video it does not show any errors. The code that I am referring to is :
    function myLoggerClass() {
    return class Logger {
    private completeLog: string = "";
    log(str: string) {
    console.log(str);
    this.completeLog += `${str}
    `;
    }
    dumpLog() {
    return this.completeLog;
    }
    }
    }

  • @muhammadarslanrana942
    @muhammadarslanrana942 Рік тому

    I think we can do the same by extending the class? Building functionality on top of another class.

    • @jherr
      @jherr  Рік тому +1

      But can you add the same functionality to multiple classes with different class tree roots without copy and paste? That's what mixins gives you.

    • @muhammadarslanrana942
      @muhammadarslanrana942 Рік тому

      @@jherr awesome thanks for the clarification.

  • @huzbum
    @huzbum Рік тому

    I think a function that returns a function is called a curried function.

  • @aleenshrestha8119
    @aleenshrestha8119 Рік тому +1

    vscode themes??

  • @Abondano1
    @Abondano1 2 роки тому +1

    wtf genial!

  • @SyedZainUlHasan
    @SyedZainUlHasan Рік тому

    I watched the full video but still not sure where to use this abnormal thing (Mixins).

    • @jherr
      @jherr  Рік тому

      Maybe adding logging to existing un-logged classes?

  • @TheGameCrafter
    @TheGameCrafter Рік тому +2

    No BS, this series is the only reason I didn't throw out typescript and run it over with a car.

  • @saeedbayat4271
    @saeedbayat4271 11 місяців тому

    Why we don't just extend the class that we want to add new functionality to it?!

  • @patrickkaipainen3301
    @patrickkaipainen3301 Рік тому

    wait....ya'll use classes? No shade. I just don't get out much from React land.

    • @jherr
      @jherr  Рік тому

      Some folks still do, but yeah, in React, not so much.

  • @DiegoBM
    @DiegoBM Рік тому +1

    My god Mixins are awful.... The tutorial is great though.