Although I am familiar with Java, TypeScript is fairly new to me. In Java, lambda expressions (->
) or method references (::
) are commonly used to satisfy functional interfaces.
It seems like lambda expressions function similarly in both languages (please correct me if I'm mistaken). However, I'm curious if there is a way to incorporate method references in TypeScript as well?
Suppose we aim to achieve the following:
this.entryService.getEntries()
.subscribe(entries => this.listUpdateService.send(entries));
Is it possible to use a function reference instead? There seems to be an issue when attempting the following approach, because send
isn't executed within the scope of this.listUpdateService
. (By the way, in which scope does it execute?)
this.entryService.getEntries()
.subscribe(this.listUpdateService.send);