Disposable in TypeScript: Explicit Resource Management

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ส.ค. 2024

ความคิดเห็น • 14

  • @Luxcium
    @Luxcium 7 หลายเดือนก่อน +5

    You are so charismatic. I each time feel like you are probably the best friend, coworker, uncle, husband, father, brother, mentor, _cousin, grandfather(?), neighbor, teacher, coach, leader, colleague, role model, advisor, confidant, supporter, godfather, partner, buddy, pal, associate, ally, comrade, teammate, companion, guide, protector, hero, inspiration, guardian, benefactor, cheerleader, sympathizer, advocate, and champion._ (after mentor it is all ChatGPT but I wanted to make it clear how much I love to see your videos and how they make me feel good)… 🎉🎉🎉🎉

  • @dimitrimitropoulos
    @dimitrimitropoulos 7 หลายเดือนก่อน +2

    great to see more resources covering this topic!

  • @IkraamDev
    @IkraamDev 7 หลายเดือนก่อน +1

    Nice Neovim setup.

  • @Luxcium
    @Luxcium 7 หลายเดือนก่อน +1

    I love your videos they are very amazing because they are instructive but I am such a nerd that I would rather say they are entertaining 😅😅😅😅

  • @studiowebselect
    @studiowebselect 7 หลายเดือนก่อน +2

    potential bug a 10:42 if tPrime have already an Symbol.dispose.
    You should combine tPrime Symbol.dispose if exist with your new one.
    Also, its an javascript feature, not typescript.

    • @andrew-burgess
      @andrew-burgess  7 หลายเดือนก่อน +1

      ooh, yup, good catch. calling the existing dispose first is exactly the right call.

  • @smash3689
    @smash3689 7 หลายเดือนก่อน +2

    Maybe wrapping the "T" object (monad approach) instead of monkey patching it would be better..? 🤷‍♂️dunno great video regardless!
    Also the fact that you can keep the instance alive after the "dispose" method call was interesting (in your "pool" example, the "dispose" method puts the object into the pool list byitself, keeping the object from being removed by gc. Potential side effect concern? This "pool" thing is very new to me cause i'm just a junior front end dev. Would love to know if keeping the object from dying by gc by destructor-method-thingy is a common pattern/practice. Sorry for poor english ).

  • @theyreMineralsMarie
    @theyreMineralsMarie 7 หลายเดือนก่อน

    You could create a "Poolable" class/interface that Summer implements. That would would be the Java way at least.

  • @meyou118
    @meyou118 7 หลายเดือนก่อน

    you could wrap or extend a new class, where the new class knows how to be pooled

  • @adamszalkowski8226
    @adamszalkowski8226 7 หลายเดือนก่อน

    Is there any mechanism that checks if the to-be-disposed object leaks out of the scope?
    Rust has the borrow checker for that purpose.

  • @juanferrer5885
    @juanferrer5885 6 หลายเดือนก่อน

    Andrew I need your help, i tried to build reduce for fun but im stuck, i need your TS knowledge, its a funny exercise
    `
    const reducee = (
    array: T[],
    cb: (accumulator: U, val: T, index: number, array: T[]) => U,
    initial?: U
    ) => {
    for (let i = 0; i < array.length; i++) {
    let acc = initial ;
    if (initial === undefined) {
    acc = array[0];
    continue;
    }
    acc = cb(initial, array[i], i, array);
    }
    return initial;
    };
    `

  • @user-fed-yum
    @user-fed-yum 7 หลายเดือนก่อน

    So it's somewhat like a c++ destructor? The design seems inconsistent with the rest of the language. I can't see how one could reasonably justify this is a necessary feature in its current form. Seems like astronaut architecture to me. Anyway, I'll stick with try finally for the time being.

  • @thinkingdev102
    @thinkingdev102 7 หลายเดือนก่อน

    Any Queueable thing can be made handy with dispose / asyncDispose.
    1. Any Email Builder
    async using _ = mail(body).to(recipients)
    2. Any Queue Job Dispatcher.
    dispatch(job).
    This will help with not waiting for these to finish before sending the response.

  • @HoNow222
    @HoNow222 7 หลายเดือนก่อน

    this is the most awkward camera angle in youtube history