КОМЕНТАРІ •

  • @raulkantor
    @raulkantor 4 роки тому +12

    you saved my life man! thank you soo much
    this is perfect i understood everything, you're such a great teacher!!!
    i'm gonna be recommending memberships for your website to _EVERYONE_

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

    Lot of respect for you sir! I want to switch to Kotlin and try to find some good tutorials. I must say no one is better than you in android here on UA-cam! Thank you soo much for these videos.

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

    Just like your teaching skill a lot, U r a great teacher, the most imp thing in this video is how you build a repository class...Thanks again for the great stuff.

  • @larrevick
    @larrevick 4 роки тому

    Your smooth and clear voice is making the tutorial more enjoyable. You're talented 👏

  • @gauravmalltarlok5354
    @gauravmalltarlok5354 5 років тому +3

    0 Dislikes...That is just evidence of how amazing this video is!

  • @baijusharma6027
    @baijusharma6027 5 років тому +3

    Thanks for taking an effort to teach us in the easiest way.

  • @oscarivan7697
    @oscarivan7697 5 років тому +6

    I'm waiting for your new course, i'm excited to learn MVI architecture

  • @GakisStylianos
    @GakisStylianos 5 років тому +37

    Timestamps:
    00:00 - Intro
    01:51 - What is a singleton?
    04:26 - Practical example of a simple singleton in code
    06:09 - Actually writing the singleton class
    09:45 - A real, much more practical example
    10:26 - Dependencies required
    11:03 - Start of coding after dependencies are done
    15:20 - Diagram on MVVM (explanation on MVVM and a bit on MVI)
    16:55 - End of explanation on MVVM (and MVI) back to coding
    31:58 - End of coding, wrap up and talk about the upcoming courses

    • @codingwithmitch
      @codingwithmitch 5 років тому +9

      You the real MVP

    • @GakisStylianos
      @GakisStylianos 5 років тому +11

      @@codingwithmitch No, you are the real MVP for providing us with all this quality free (and quality paid xD) content. I just thought I'd help out some of my fellow learners :)

  • @DanielyBotelho
    @DanielyBotelho 5 років тому +3

    Thank you Mitch!!!
    I love your videos. The subject is very interesting and you speak very clearly with an easy to understand explanation. My English is very basic but I can understand everything that speaks perfectly. Thank you so much!

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

    Hey, I love your videos! Just for the record , I do care about the little bits of over information you give such as the description of Gson. Every little bit helps paint a picture when I am trying to determine best practices and important libraries. Thanks for the video.

  • @ViralJoshiVirus
    @ViralJoshiVirus 5 років тому

    Mitch thats really fascinating. I dont know when I am goanna go with your all courses. Really good stuffs.!!! And its like day by day new libraries and new architecture are showing up. Got so many things to learn man!!! I wish one day i will complete all your courses.

  • @awzsdrcfgybhjimklp
    @awzsdrcfgybhjimklp 5 років тому +1

    13:18 Yes I absolutely cared about that quick bit of information! It saved me from having to look it up myself!

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

    Amazing tutorial, u are my new favorite channel. Have subcribed and liked,
    Keep working hard Mr Mitch :D

  • @Warlax
    @Warlax 4 роки тому

    Great video Mitch. One quick note (apologies if people already pointed this out): hashCode is not the object address/reference in memory (unless you didn't override it, in which case, it's default implementation actually is - Kotlin overrides hashCode() for data classes). hashCode() returns hash value of the fields of the instance of the class; in fact, by design, two instances of the same class with the same field values should hash to the same hash code or "equals" wouldn't work.
    What you are looking for is System.identityHashCode(Object) -- docs.oracle.com/javase/6/docs/api/java/lang/System.html#identityHashCode%28java.lang.Object%29

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      yeah I gave the incorrect description. Someone already pointed that out. But thanks

  • @hamitaksln
    @hamitaksln 4 роки тому

    Instead of putting cancelJobs function into onDestroyed wouldn't it be better if we put it into onCleared in viewModel ? Thanks for the great tutorial.

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

    As always amazing video and great explanations.
    Quick question: Isnt that way to set LiveData in the Repository a little bit weird? Wouldnt you normally use methods like postValue for that? I've never seen this done like that in Java so I am confused why it is done like this in Kotlin. Thanks in advance.

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

    Great job explaining Singletons!

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

    30:32 I think you could've cancel the jobs in the onClear method on viewmodel, that way it would cancel automatically when the activity is destroyed.

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

    In the documentation it says that the instance of a Singleton is created the first time you uses it; So, is not created right when you declare it, and this implicitly means that it is lazy initialization. Therefore, isn't redundant to initialize the Singleton by lazy?

  • @aquaticaquatos4792
    @aquaticaquatos4792 5 років тому

    Your videos would be THE best video if you could teach us to use the design patterns in different scenarios like, login logout session, filling and submitting forms, network check and load content for placeholder, recyclerview with actions, etc

  • @emanalsbeiheen5619
    @emanalsbeiheen5619 4 роки тому

    Hi Mitch great video... Why you did'nt use moshi..? Instead of Gson

  • @muhannddh
    @muhannddh 4 роки тому

    The viewModelScope is bounded to ViewModel’s lifecycle. It has created to automatically handle cancellation when the ViewModel’s onClear() is called. So if we are going to use that I think we don't need the viewModel.cancelJobs(), Right?

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

    Very helpful Mitch, as always

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

    Why don't you execute "Repository.cancelJobs()" in the MainViewModel.onClear() method?

  • @NasifAhmed002
    @NasifAhmed002 4 роки тому

    What if I don't use lazy? If I just initialize the variable, what will be the problem?

  • @omercemcicekli6878
    @omercemcicekli6878 4 роки тому

    Loving the work you do, thanks. Just a suggestion. You should cancel jobs on the ViewModel onCleared method. It triggers when activity destroyed, basically same thing you do on activity onDestroy method.

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

    Great video 👍 one question is if Retrofit already runs in background thread, why use coroutines?

  • @IvanGarcia-sg8hj
    @IvanGarcia-sg8hj 4 роки тому

    First of all Thank you for the video! I will become a member as soon as possible.
    I have a question, What if my getUser method needs two parameters? What can I do?

  • @afinasem8471
    @afinasem8471 5 років тому +5

    Hi, I'm developer from India. I'm wondering that, how do I handle retrofit errors by following this code?

    • @anoopghildiyal6413
      @anoopghildiyal6413 5 років тому

      I am also looking for the same...

    • @saidooubella
      @saidooubella 4 роки тому

      TL;DR : Put it in a try catch block.
      Check kotlin coroutine 101 from Android developers channel to learn more.

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

      In ApiService, you can change function return type from User to Response and inside Repository set value = user.body, before that you can check if user.isSuccessfull() and also you can wrap the whole thing inside try/catch for exception,

  • @farasatali2523
    @farasatali2523 4 роки тому

    HI, for some reason when I initialize job = Job() I get build errors , no matter how many time I try android studio calls it Unresolved , what might be the issue?

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

    Very useful Mitch. Thanks a lot.

  • @sisandroid5022
    @sisandroid5022 4 роки тому

    Hi Mitch,
    To handle network related exception do we need to go with Rx or we can handle that through coroutine as well??

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

      Yeah you can handle with coroutines. If there's an error just return an error state. ex: github.com/mitchtabian/Open-API-Android-App/blob/master/app/src/main/java/com/codingwithmitch/openapi/ui/DataState.kt.
      If you want to see examples watch this course: codingwithmitch.com/courses/powerful-android-apps-with-jetpack-architecture/

    • @sisandroid5022
      @sisandroid5022 4 роки тому

      @@codingwithmitch
      Great
      Thanks a lot :)

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

    Thanks to the author, great video.

  • @abbasalidaruwala
    @abbasalidaruwala 4 роки тому

    @codingwithmitch Tq for the tutorial why can't we use .build() inside retrofitBuilder lazy function it give some error of inline functions

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

    Hey Hi Mitch,
    I really love the way you explain the things...
    So can you please help us on how to handle network errors like 'No Internet', response with error code 404,500 etc in CoroutineScope...
    currently I am getting below error
    FATAL EXCEPTION: DefaultDispatcher-worker-2
    retrofit2.HttpException: HTTP 404 Not Found

  • @ManishPatel3030
    @ManishPatel3030 4 роки тому

    Very good session thanks for c cool video 👌

  • @abdelrahmangamal8575
    @abdelrahmangamal8575 4 роки тому

    great video but why in Repository.kt you used this method override fun onActive() {} why you not use liveData{} block and emit() function
    and why in viewmodel you not use Repository as DI
    thanx

  • @PreetiWadhwani2592
    @PreetiWadhwani2592 4 роки тому

    Amazing video, learned so much. Can't wait for more videos, thank you for making it!

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

    Very nice content!!! Lots of thing in single video great!! Thanks #YouRock

  • @sherazali6324
    @sherazali6324 5 років тому +1

    I needed that One. Thanks Mitch

  • @tobennaezike9650
    @tobennaezike9650 5 років тому +1

    Awesome tutorial mitch

  • @AbhishekChauhan321
    @AbhishekChauhan321 5 років тому

    When are you planning to release your next course on your website?

    • @codingwithmitch
      @codingwithmitch 5 років тому

      The MVI course prob in 1-2 weeks then the powerful android apps course

  • @neerajsewani5764
    @neerajsewani5764 5 років тому

    This time I noticed Kodein written on the board in the back. Any plans on making videos on that?

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

    Is it a good practice to use live data in repository for a very large code base app

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

      I wouldn't use live data in a repository at all. Suspend functions are the way

  • @arpitgupta3151
    @arpitgupta3151 4 роки тому

    Can you create a full course on Retrofit with Put, Patch and delete functions?

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      I have lots codingwithmitch.com/courses/powerful-android-apps-with-jetpack-architecture/

  • @hnim2292
    @hnim2292 4 роки тому

    34:53 definitely me lol
    come back here from MVI course for practice more about kotlin to keep up with the course.

  • @sogodeveloper7015
    @sogodeveloper7015 5 років тому

    this is really great thanks. however one thing - how can/do we pass an error message back to the UI using this pattern ? eg. the Retrofit API call fails for whatever reason. can you add this to the example ?

    • @codingwithmitch
      @codingwithmitch 5 років тому

      That's what the powerful android apps course is for. Showing you a more detailed use case. There will be an offline cache, error handling, everything you need. codingwithmitch.com/courses/powerful-android-apps-with-jetpack-architecture/

  • @trungnguyenhoang719
    @trungnguyenhoang719 5 років тому

    Thanks Mitch. This video is very helpful for me

  • @dmitrybelyaev6120
    @dmitrybelyaev6120 4 роки тому

    What if we have an error? For example, no internet connection. This case our app will crash

  • @Mr47even
    @Mr47even 4 роки тому

    How do you handle retrofit chain calls with coroutine ?

  • @swornimshah8898
    @swornimshah8898 5 років тому

    shouldn't the co routine be written in viewmodel coroutine scope so that when activity or fragment gets destroyed the coroutine gets cancelled automatically but in your case the network repository coroutine is still running or waiting for the data?? may be i am wrong

    • @codingwithmitch
      @codingwithmitch 5 років тому +1

      You could use the viewmodelscope. I've been putting the job in the repository.

  • @karan548
    @karan548 5 років тому +2

    Great video Mitch. Can you please make a video about MVI architecture. Thanks a lot!

    • @codingwithmitch
      @codingwithmitch 5 років тому +1

      Yep I will

    • @aks4125
      @aks4125 5 років тому

      @@codingwithmitch Please we need one more MVI architecture using coroutines + retrofit. Thanks.

    • @codingwithmitch
      @codingwithmitch 5 років тому

      @@aks4125 I got a course brother codingwithmitch.com/courses/model-view-intent-mvi-architecture/

  • @hichamraf8226
    @hichamraf8226 4 роки тому

    You could as well override OnColeared on the ViewModel to call cancel jobs

  • @Mr47even
    @Mr47even 4 роки тому

    Hi Mitch,
    Awesome turorial as always ...
    Could ie be possible to make a tutorial about unidirectional data flow as a best practice ?

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

    What is @Expose for?

  • @andri_sul
    @andri_sul 5 років тому

    Thank you! your video is easy to understand

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

    Really your awesome sir

  • @AkshayTaru
    @AkshayTaru 5 років тому

    Can't we cancel job in viewmodelScope like
    override fun onCleared() {
    //

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      I prefer to do it in the repository because I like to create a new job for each event. If I canceled the ViewModelScope it would cancel all jobs instead of just the single event.

  • @sufyanshabbir1834
    @sufyanshabbir1834 5 років тому +1

    Mitch you are love.

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

    thanks, here is your comment for the youtube algoritm

  • @dibyendusamanta6112
    @dibyendusamanta6112 4 роки тому

    Thank you, it is very helpful. Can you show the error handling with this example like 404 or No Internet connection and Progress loader, so that it will a complete solution? waiting for the tutorial.

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      Y it's right here man codingwithmitch.com/courses/model-view-intent-mvi-architecture/

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      The other courses I have are also complete solutions

  • @omidmirrajaee8054
    @omidmirrajaee8054 4 роки тому

    Hi Mitch:
    i have one question
    in callback what is mean this part
    "Code that heavily uses callbacks can become hard to read and harder to reason about"
    developer.android.com/courses/extras/multithreading#callbacks

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

    Awesome tutorial!

  • @ahmedshabaan7656
    @ahmedshabaan7656 4 роки тому

    Hi Mitch
    your tutorial is very awesome i will subscribe in you website asap
    but i need to ask you about if u are using usecase pattern or not and koin for DI and TTD
    Thank you again for awesome explanation

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      I don't know what usecase pattern is

    • @ahmedshabaan7656
      @ahmedshabaan7656 4 роки тому

      @@codingwithmitch
      You can see this article and you will understand me
      “Android clean architecture with ViewModel, UseCases and Repositories: Part 1” by Antoni Castejón García proandroiddev.com/android-clean-architecture-with-viewmodel-usecases-and-repositories-part-1-b9e63889a1aa

  • @sabinjose
    @sabinjose 4 роки тому

    Thank you for this awesome tutorial!

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

    How to use retrofit service callback class

  • @sergeygolovin9523
    @sergeygolovin9523 5 років тому

    What will happen when you call another getUser while previous is not completed? Don't you should call job.cancel() in the beginning of Repository.getUser?

    • @codingwithmitch
      @codingwithmitch 5 років тому

      What you would actually want to do is have a job object inside the NetworkBoundResource. That way it's unique to the request

    • @codingwithmitch
      @codingwithmitch 5 років тому +1

      Actually I missunderstood what you were asking. You don't need to because of the switchmap. The unique properties of a switchmap ensure only one observable is emitted at any given time. So if you searched again it would be terminated already through the switchmap.

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

    you know me so well 😙

  • @jitendrakumar3385
    @jitendrakumar3385 5 років тому

    How can I show and hide progress dialog on api request and response with this example?

    • @codingwithmitch
      @codingwithmitch 5 років тому +1

      By watching my mvi course my friend codingwithmitch.com/courses/model-view-intent-mvi-architecture/

  • @ajaysharma-ez5ms
    @ajaysharma-ez5ms 4 роки тому

    I want to know how to handle 401,404,500 error using kotlin coroutines

  • @pankajkumargt
    @pankajkumargt 4 роки тому

    You are amazing man... 🙏🙏🙏
    Funny things Id 2 will not work 😁😁

  • @irfanirawansukirman4809
    @irfanirawansukirman4809 5 років тому +1

    Great mitch 👍

  • @fabrizioalmeida8435
    @fabrizioalmeida8435 5 років тому +3

    Thank you so much!, If I could I doin a lot of likes for you.

  • @sherazali6324
    @sherazali6324 5 років тому

    Do you have any slack channel where we can ask questions??

    • @codingwithmitch
      @codingwithmitch 5 років тому

      Discord channel. But it's for members only. codingwithmitch.com/enroll/
      With a membership you get access to all my courses and offline downloads codingwithmitch.com/courses/

  • @samo92mx
    @samo92mx 4 роки тому

    Have you got a tutorial with viewModelScope?

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

    Thank you🙏 Dhanyawad

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

    real help man!

  • @sagarghare9829
    @sagarghare9829 4 роки тому

    Great 36 minutes video. Learn something good.

  • @bogdankolomiiets2799
    @bogdankolomiiets2799 4 роки тому

    Awesome. Thank you.

  • @chiragprajapati3989
    @chiragprajapati3989 5 років тому +1

    great tutorial 👌

  • @kumarraja93
    @kumarraja93 5 років тому

    Why mvvm is used only in kotlin, is it not possible for java developent??

    • @codingwithmitch
      @codingwithmitch 5 років тому +1

      yes you can use java or kotlin

    • @kumarraja93
      @kumarraja93 5 років тому

      Is good to change to Kotlin or to maintain in java in android app development.?

    • @codingwithmitch
      @codingwithmitch 5 років тому +1

      @@kumarraja93 I would switch to kotlin

    • @kumarraja93
      @kumarraja93 5 років тому +1

      @@codingwithmitch thank you mitch

  • @rooneyviet
    @rooneyviet 4 роки тому

    Great tutorial!!

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

    How to use coroutine scope in Android service

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

    Amazing

  • @jitendrakumar3385
    @jitendrakumar3385 5 років тому +1

    Awesome thanks

  • @sherazali6324
    @sherazali6324 5 років тому

    Can you make a complete lecture on Room Persistence Library ?? :(

    • @codingwithmitch
      @codingwithmitch 5 років тому +1

      I have a free course codingwithmitch.com/courses/sqlite-room-persistence-android/

    • @sherazali6324
      @sherazali6324 5 років тому +1

      @@codingwithmitch Thank You

  • @alirzayucefaydal591
    @alirzayucefaydal591 4 роки тому

    i don't know why but when i use only IO or Main, it gives an arror. So i have to use Dispatchers.IO

  • @alitonoliveira1700
    @alitonoliveira1700 5 років тому

    I've never seem Room plus Firebase using MVVM structure.

  • @CasperBang
    @CasperBang 4 роки тому

    I like your video's very much, but hashCode is NOT a memory address in any way. For that you will have to do something like sun.misc.Unsafe.getAddress(..)

  • @farhad9579
    @farhad9579 5 років тому

    hey mitch i realy like to give u money for course but i dont have: ... WISH i could reach to your member required Courses in your site

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

    I think you should cancel job in ViewModel when onCleared fun called

  • @mrsoommy9162
    @mrsoommy9162 4 роки тому

    Should I have separate repositories for each of my view models?

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

    Thank you

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

    Please make video for kotlin flows

  • @tanmaysahoo4783
    @tanmaysahoo4783 4 роки тому

    Thanks for it

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

    You are giving a bad example of using singletons everywhere. I guess it's just to show that they exist, but you forgot to mention how bad it will be fot testing everything when only singletons are used.
    And in Repository.kt if you call getUser twice, you will be able to cancel only last job since you overwrite your job variable. And simple fix like canceling job before rewriting it won't work either cuz u may use this function all over your app and it's not ok to expect it not to work sometimes. This place need some refactoring. A guess this is, again, for demonstration purposes but the devil is in the details. You had to at least mentioned it.
    Apart from those small but very important details, great vid.

  • @slavromanov1637
    @slavromanov1637 4 роки тому

    CodingWithMitch , please have a look what does "hashCode" really mean, how it is generated and then eventually use it to prove your theories. As in your example the hashcode is the same. before and after the rotation, because of the properties of the singleton object not because of the address of the singleton in the memory. Please edit your video, so the people that are going to watch the video, won't be misguided. Good luck :)

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      So the hashcode will only change if the properties of the object change? I always thought (new hashcode) = (new object instance)

    • @slavromanov1637
      @slavromanov1637 4 роки тому

      @@codingwithmitch hashcode is generated based on the values of the object members. For example if you create another singleton object with the same object property values, the hashcode would be the same. The rule is that objects with equal property values have the same hashcode,and that's why if you'd like to have equals working you have to have equal hashcodes for the objects you are comparing.

    • @codingwithmitch
      @codingwithmitch 4 роки тому

      @@slavromanov1637 Interesting. Thanks for clearing that up. Just to make sure I understand correctly. Consider this example:
      I have a singleton POJO with two string parameters. If I set the two string parameters to some values (call them "val1" and "val2"). Then do a config change or however you want to force the object to be destroyed. If I create another singleton and set the values to the exact same ("val1" and "val2"), it will have the same hashcode?

    • @slavromanov1637
      @slavromanov1637 4 роки тому

      @@codingwithmitch Instead of asking me why don't you check it in the IntelliJ Idea IDE?

    • @slavromanov1637
      @slavromanov1637 4 роки тому

      @@codingwithmitch Their's hashcodes will be the same.

  • @mohanakrishna96
    @mohanakrishna96 5 років тому

    Hello Mitch
    I am new to your videos. Can you possibly sometime do video on viewmodelscope available in androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0?

    • @codingwithmitch
      @codingwithmitch 5 років тому

      Probably. I don't usually use it because I usually do asynchronous work in the repository.

  • @amirs6472
    @amirs6472 4 роки тому

    great

  • @andy_lamax
    @andy_lamax 5 років тому +2

    I don't think this is the best approach to use Singletons with LiveData. your LiveData from repository is always creating a new Singleton Object. Kinda defeats the purpose

    • @codingwithmitch
      @codingwithmitch 5 років тому

      No. It's accessing the Singleton. Not creating a new one.

    • @andy_lamax
      @andy_lamax 5 років тому

      @@codingwithmitch No, it is not. your method always returns a newly created singleton. try asking someone else for a 2nd opinion if you don't believe me

    • @codingwithmitch
      @codingwithmitch 5 років тому

      @@andy_lamax I will check tomorrow

    • @codingwithmitch
      @codingwithmitch 5 років тому +4

      Yes it still returns the same instance. Use this code for the Repository and MainActivity and look at the log output for the hashcode of the ApiService. It's the same location in memory.
      gist.github.com/mitchtabian/f7e152b0ca2881e5238a96f8177f7eca

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

      Just revisited this video, and rewatched and found the very same issues. I am referring to the object created in Repository.kt that is returned by the `getUser(userId: String)` method. It is always a new object.
      An object is only considered a singleton, when it is nested in a class, not as an inner object but just as an object or when it is a top level object. Constructing an anonymous object (regardless it extends another class/entity), wont return a singleton. Also, class properties that are assigned to objects (anonymous or not) will always have a different addresses for different instances of the class
      To prove my point, try calling Repository.getUser(userId: String) twice, you will realize that the two instances are different and they are from different memory addresses as well. Although, they will probably serve the same content but as I said earlier, it does defeat the purpose