X Tutup
Skip to content

feat(http): expose API as class with helper methods, plus optional factory #2530

@jeffbcross

Description

@jeffbcross

In order to achieve a simple experience with the new http library, and to somewhat match the API of AngularJS 1.x, the http service was implemented as an injectable function as the only way to use. There are a few usability costs with the current approach.

  • An interface, IHttp, must be provided and used alongside Http injection in order to provide type information: constructor(@Inject(Http) http:IHttp)
  • It would be nice to have shorthand methods, like .get(), .post(), etc to reduce boilerplate. These could be added onto the http function, but...
  • Decorating the http factory with these methods would cause TypeScript to not know about the additional methods.

New Design:
Keep current workflow as an option, but require injecting HttpFactory instead of Http, and make Http an injectable class with methods: request, get, put, delete, post.

Metadata

Metadata

Assignees

Labels

featureLabel used to distinguish feature request from other issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup