Understanding TypeScript Interfaces



An interface is a programming feature that helps to define the expected structure of an object allowing that to serve as a contract of sorts for the class where it is implemented.



That helps explain the concept but how does this actually translate into working with real world code?

Let’s say for example we have the following method:

1
2
3
4
public requestSpecificArea(lat : number, lng : number) : Observable
{
  return this.http.get(this._api + `locate-neighbourhood?q=${lat},${lng}`);
}

As you can gather from the code we’re using Angular’s HttpClient class to query a remote API which returns data as an observable that we can subsequently subscribe to.


Comments

Popular posts from this blog

Hire Top AngularJS Development Companies & Developers

Quickly Create Real Angular Prototypes Without Writing Code

Python’s Fake Increment and Decrement Operators