Giter VIP home page Giter VIP logo

Comments (1)

kimdohun0104 avatar kimdohun0104 commented on June 28, 2024

백문이 불여일견 제가 직접 변경해보았습니다.

 val `this` = this@SignUpActivity
        viewModel.run {
            showLoadingDialogEvent.observe(`this`, Observer { LoadingDialog.show(supportFragmentManager) })

            hideLoadingDialogEvent.observe(`this`, Observer { LoadingDialog.hide() })

            finishActivityEvent.observe(`this`, Observer { finish() })

            toastEvent.observe(`this`, Observer { toast(it) })

            signUpLogEvent.observe(`this`, Observer { Analytics.logEvent(`this`, Analytics.SIGN_UP, it) })
        }

위 코드에서 볼 수 있듯이 Analytics.logEvent 에는 context가 들어가지만 this@SignUpActivity를 통해 Context를 넘겨줄 수 있습니다.
그래서 lifeCycleOwner로만 this가 사용되지 않는 사실을 확인할 수 있습니다.
하지만 this라는 이름의 변수는 선언할 수 없습니다.
그래서 다양한 이름 중 `this`로 결정했습니다.
` ` 로 감싸주면 기본 신택스도 변수이름으로 사용할 수 있습니다.

실제로 적용해보니 생각보다 느낌있네요.
그래서 모두 변경하려고 합니다.
감사합니다

from dsmmarket.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.