X Tutup
Skip to content

refactor(Http): remove HttpFactory #2564

@jeffbcross

Description

@jeffbcross

There are two things that can be injected in order to perform Http requests, Http or HttpFactory. Http is a class with the primary method of request, plus some shortcut methods like get, post, etc. HttpFactory is a function equivalent to Http.request.

I think having HttpFactory adds more concepts/complexity than is warranted, and I'd like to remove it. For one, it requires two more pages of documentation. One page to document the factory itself, and another to document the IHttp interface that exists solely to provide type information for the factory.

// Factory
import {HttpFactory, IHttp} from 'angular2/http';
class MyComponent {
  constructor(@Inject(HttpFactory) http:IHttp) {
    http('angular.json').subscribe(ng => this.angular = ng);
  }
}

// Class
import {Http} from 'angular2/http';
class MyComponent {
  constructor(http:Http) {
    http.request('angular.json').subscribe(ng => this.angular = ng);
  }
}

The idea of having a simple callable function instead of calling a class method is nice, but I think the trade-off of additional concepts isn't worth the overhead.

@Blesh @caitp what do you two think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup