Skip to content

Instantly share code, notes, and snippets.

@ericntd
Created January 18, 2022 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericntd/28652d29eb8d6b01f2cd9367645c626e to your computer and use it in GitHub Desktop.
Save ericntd/28652d29eb8d6b01f2cd9367645c626e to your computer and use it in GitHub Desktop.
Late injection through constructor input streams
class MatchPresentationLogics(
    private val bagel: Bagel,
    private val banState: Observable<BanState>
) {
   init {
       banState.subscribe {
           // do what's necessary
       }
   }
}

Usage

// initialization
val banStateSubject = PublishSubject.create<BanState>()
val presenter = MatchPresentationLogics(bagel, banStateSubject)
...
// Sometimes later
banStateSubject.onNext(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment